History

media: rppx1: bls: Add support for black level compensation

Extend the RPPX1 driver to allow setting the black level measurement and gain configuration. It uses the RPPX1 framework for parameters and its writer abstraction to allow the user to control how, and when, configuration is applied to the RPPX1.

Niklas Söderlund committed 3 months ago

Commit 3f8a2a81 parent 9a52f7d4 files · +209 −1Browse files

Showing the changes to include/uapi (1 of 4 files). Show all

Unified · Split

include/uapi/linux/media/dreamchip/rppx1-config.h+106−1
@@ -85,6 +85,8 @@ enum rppx1_meas_chan { · 84 unmodified lines
8585 * @RPPX1_PARAMS_BLOCK_TYPE_HIST_PRE1: PRE1 pipe Histogram Measurement
8686 * @RPPX1_PARAMS_BLOCK_TYPE_HIST_PRE2: PRE2 pipe Histogram Measurement
8787 * @RPPX1_PARAMS_BLOCK_TYPE_HIST_POST: POST pipe Histogram Measurement
88+ * @RPPX1_PARAMS_BLOCK_TYPE_BLS_PRE1: PRE1 pipe Black Level Subtraction
89+ * @RPPX1_PARAMS_BLOCK_TYPE_BLS_PRE2: PRE2 pipe Black Level Subtraction
8890 */
8991 enum rppx1_params_block_type {
9092 RPPX1_PARAMS_BLOCK_TYPE_WBMEAS_POST,
@@ -96,6 +98,8 @@ enum rppx1_params_block_type { · 5 unmodified lines
9698 RPPX1_PARAMS_BLOCK_TYPE_HIST_PRE1,
9799 RPPX1_PARAMS_BLOCK_TYPE_HIST_PRE2,
98100 RPPX1_PARAMS_BLOCK_TYPE_HIST_POST,
101+ RPPX1_PARAMS_BLOCK_TYPE_BLS_PRE1,
102+ RPPX1_PARAMS_BLOCK_TYPE_BLS_PRE2,
99103 };
100104
101105 /**
@@ -330,6 +334,105 @@ struct rppx1_hist_params { · 228 unmodified lines
330334 __u8 reserved;
331335 };
332336
337+/**
338+ * struct rppx1_bls_fixed - BLS fixed subtraction values
339+ *
340+ * Fixed black level values subtracted from sensor data per Bayer channel.
341+ * Negative values result in addition.
342+ *
343+ * The PRE1 pipe BLS module operates on a 24-bits input data and fixed black
344+ * levels are stored as a signed 2's complement representation ranging from
345+ * -2^24 to 2^24-1.
346+ *
347+ * The PRE2 pipe BLS module operates on a 12-bits input data and fixed black
348+ * levels are stored as a signed 2's complement representation ranging from
349+ * -2^12 to 2^12-1.
350+ *
351+ * Userspace is expected to provide fixed black level values with a bit-depth
352+ * matching the one of pipe in use.
353+ *
354+ * These subtraction values are matched with the sensor native Bayer components
355+ * ordering according to the cropping configuration on the input port.
356+ *
357+ * @a: subtraction value for channel A
358+ * @b: subtraction value for channel B
359+ * @c: subtraction value for channel C
360+ * @d: subtraction value for channel D
361+ */
362+struct rppx1_bls_fixed {
363+ __u32 a;
364+ __u32 b;
365+ __u32 c;
366+ __u32 d;
367+};
368+
369+/**
370+ * enum rppx1_bls_mode - BLS subtraction mode
371+ *
372+ * Select if subtracted black level come from fixed or measured values.
373+ *
374+ * @RPPX1_BLS_MODE_FIXED: subtract fixed values
375+ * @RPPX1_BLS_MODE_MEAS: subtract measured values
376+ */
377+enum rppx1_bls_mode {
378+ RPPX1_BLS_MODE_FIXED,
379+ RPPX1_BLS_MODE_MEAS,
380+};
381+
382+/**
383+ * enum rppx1_bls_win_en: BLS measurement configuration
384+ *
385+ * Select the measurement window to use for measured black level values.
386+ *
387+ * @RPPX1_BLS_WIN_EN_OFF: disable measurement
388+ * @RPPX1_BLS_WIN_EN_WIN1: Enable measurement from window 1
389+ * @RPPX1_BLS_WIN_EN_WIN2: enable measurement from window 2
390+ * @RPPX1_BLS_WIN_EN_WIN12: enable measurement from window 1 and window 2
391+ */
392+enum rppx1_bls_win_en {
393+ RPPX1_BLS_WIN_EN_OFF,
394+ RPPX1_BLS_WIN_EN_WIN1,
395+ RPPX1_BLS_WIN_EN_WIN2,
396+ RPPX1_BLS_WIN_EN_WIN12,
397+};
398+
399+/**
400+ * struct rppx1_bls_params - RPP-X1 Black Level Subtraction Module
401+ *
402+ * The RPP-X1 Black Level Subtraction module is available on the PRE1 and PRE2
403+ * pre-fusion pipes. Userspace selects which pipe to operate by setting the
404+ * @header.type field to RPPX1_PARAMS_BLOCK_TYPE_BLS_PRE1 or
405+ * RPPX1_PARAMS_BLOCK_TYPE_BLS_PRE2.
406+ *
407+ * The BLS module operates on fixed or measured data according to the setting of
408+ * the @mode field. When RPPX1_BLS_MODE_FIXED is used userspace shall provide
409+ * the per-channel black levels in @fixed. When RPPX1_BLS_MODE_MEAS is used
410+ * userspace shall configure the measurement windows @window1 and optionally
411+ * @window2 to select the optically black pixels region in the input frame. The
412+ * @samples fields controls how many measure samples are used for averaging the
413+ * measured black levels.
414+ *
415+ * @header: block header (type = RPPX1_PARAMS_BLOCK_TYPE_BLS_PRE1 or
416+ * type == RPPX1_PARAMS_BLOCK_TYPE_BLS_PRE2)
417+ * @window1: BLS measurement window 1 (14 bits)
418+ * @window2: BLS measurement window 2 (14 bits)
419+ * @fixed: fixed subtraction values (see enum rppx1_bls_fixed)
420+ * @mode: BLS subtraction mode (see enum rppx1_bls_mode)
421+ * @en_windows: BLS measurement mode (see rppx1_bls_win_en)
422+ * @samples: log2 of the number of measured pixels per Bayer position
423+ * @reserved: padding
424+ */
425+struct rppx1_bls_params {
426+ struct v4l2_isp_params_block_header header;
427+ struct rppx1_window window1;
428+ struct rppx1_window window2;
429+ struct rppx1_bls_fixed fixed;
430+ __u8 mode;
431+ __u8 en_windows;
432+ __u8 samples;
433+ __u8 reserved[5];
434+};
435+
333436 /**
334437 * RPPX1_PARAMS_MAX_SIZE - Maximum size of all RPP-X1 parameter blocks
335438 *
@@ -345,7 +448,9 @@ struct rppx1_hist_params { · 9 unmodified lines
345448 sizeof(struct rppx1_exm_params) + \
346449 sizeof(struct rppx1_hist_params) + \
347450 sizeof(struct rppx1_hist_params) + \
348− sizeof(struct rppx1_hist_params))
451+ sizeof(struct rppx1_hist_params) + \
452+ sizeof(struct rppx1_bls_params) + \
453+ sizeof(struct rppx1_bls_params))
349454
350455 /* ---------------------------------------------------------------------------
351456 * Statistics Structures