History

media: rppx1: exm: Add support for exposure measurement

Extend the RPPX1 driver to allow setting the exposure measurement configuration and consuming the resulting statistics. 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 b020bec1 parent 9ebf5005 files · +216 −2Browse files

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

Unified · Split

include/uapi/linux/media/dreamchip/rppx1-config.h+123−2
@@ -32,6 +32,36 @@ struct rppx1_window { · 31 unmodified lines
3232 __u16 v_size;
3333 };
3434
35+/**
36+ * enum rppx1_meas_chan - Measurement point for the Histogram and EXM Modules
37+ *
38+ * Measurement points for the RPP-X1 Histogram measurement module and Exposure
39+ * measurement module.
40+ *
41+ * All tap points are available for the PRE1/PRE2 pipes. Only
42+ * RPPX1_MEAS_CHAN_SEL4 and RPPX1_MEAS_CHAN_SEL7 are available for the
43+ * MAIN_POST pipe.
44+ *
45+ * @RPPX1_MEAS_CHAN_SEL0: after input acquisition
46+ * @RPPX1_MEAS_CHAN_SEL1: after black level subtraction
47+ * @RPPX1_MEAS_CHAN_SEL2: after sensor gamma linearization
48+ * @RPPX1_MEAS_CHAN_SEL3: after lens shading correction
49+ * @RPPX1_MEAS_CHAN_SEL4: after auto white balance gains
50+ * @RPPX1_MEAS_CHAN_SEL5: after defect pixel correction
51+ * @RPPX1_MEAS_CHAN_SEL6: after denoise pre-filter
52+ * @RPPX1_MEAS_CHAN_SEL7: after demosaicing
53+ */
54+enum rppx1_meas_chan {
55+ RPPX1_MEAS_CHAN_SEL0,
56+ RPPX1_MEAS_CHAN_SEL1,
57+ RPPX1_MEAS_CHAN_SEL2,
58+ RPPX1_MEAS_CHAN_SEL3,
59+ RPPX1_MEAS_CHAN_SEL4,
60+ RPPX1_MEAS_CHAN_SEL5,
61+ RPPX1_MEAS_CHAN_SEL6,
62+ RPPX1_MEAS_CHAN_SEL7,
63+};
64+
3565 /* ---------------------------------------------------------------------------
3666 * Parameter Structures
3767 *
@@ -50,12 +80,16 @@ struct rppx1_window { · 12 unmodified lines
5080 * @RPPX1_PARAMS_BLOCK_TYPE_AWBG_PRE1: PRE1 pipe White Balance Gains
5181 * @RPPX1_PARAMS_BLOCK_TYPE_AWBG_PRE2: PRE2 White Balance Gains
5282 * @RPPX1_PARAMS_BLOCK_TYPE_AWBG_POST: MAIN_POST White Balance Gains
83+ * @RPPX1_PARAMS_BLOCK_TYPE_EXM_PRE1: PRE1 pipe Exposure Measurement
84+ * @RPPX1_PARAMS_BLOCK_TYPE_EXM_PRE2: PRE2 pipe Exposure Measurement
5385 */
5486 enum rppx1_params_block_type {
5587 RPPX1_PARAMS_BLOCK_TYPE_WBMEAS_POST,
5688 RPPX1_PARAMS_BLOCK_TYPE_AWBG_PRE1,
5789 RPPX1_PARAMS_BLOCK_TYPE_AWBG_PRE2,
5890 RPPX1_PARAMS_BLOCK_TYPE_AWBG_POST,
91+ RPPX1_PARAMS_BLOCK_TYPE_EXM_PRE1,
92+ RPPX1_PARAMS_BLOCK_TYPE_EXM_PRE2,
5993 };
6094
6195 /**
@@ -149,6 +183,66 @@ struct rppx1_awbg_params { · 87 unmodified lines
149183 __u32 gain_green_b;
150184 };
151185
186+/**
187+ * enum rppx1_exm_mode - Exposure measurement mode
188+ *
189+ * Exaposure measurement mode selection (RGB/Bayer).
190+ *
191+ * @RPPX1_EXP_MEASURING_MODE_DISABLED: no measurement
192+ * @RPPX1_EXP_MEASURING_MODE_RGB: Y/R/G/B measurement
193+ * @RPPX1_EXP_MEASURING_MODE_BAYER: Bayer RGB measurement
194+ */
195+enum rppx1_exm_mode {
196+ RPPX1_EXP_MEASURING_MODE_DISABLED,
197+ RPPX1_EXP_MEASURING_MODE_RGB,
198+ RPPX1_EXP_MEASURING_MODE_BAYER,
199+};
200+
201+/**
202+ * struct rppx1_exm_params - Exposure measurement configuration
203+ *
204+ * The RPP-X1 Exposure measurement unit is available on the PRE1 and PRE2
205+ * pre-fusion pipes. Userspace selects which pipe to operate by setting
206+ * the @header.type field to RPPX1_PARAMS_BLOCK_TYPE_EXM_PRE1 or
207+ * RPPX1_PARAMS_BLOCK_TYPE_EXM_PRE2.
208+ *
209+ * Exposure measurement is performed in the RGB or Bayer domain, according to
210+ * the setting of the @mode field. The exposure measurement tap point is
211+ * selected according to the value of @channel_sel.
212+ *
213+ * The exposure measurement is performed on an input window specified in @wnd.
214+ * To each color component a programmable weight coefficient is associated.
215+ * Coefficients are represented as unsigned 8 bits integer values in Q1.7 format
216+ * ranging from 0 to 1.992.
217+ *
218+ * The @last_line fields controls when the exposure measurement completes. It
219+ * is usually programmed to the value of (@wnd.v_offs + @wnd.v_size + 1).
220+ *
221+ * @header: block header (type = RPPX1_PARAMS_BLOCK_TYPE_EXM_PRE1 or
222+ * type = RPPX1_PARAMS_BLOCK_TYPE_EXM_PRE2)
223+ * @wnd: measurement window coordinates
224+ * @mode: exposure measure mode (from enum rppx1_exm_mode)
225+ * @last_line: line number for which the exposure measurement completes
226+ * @channel_sel: exposure measurement point (see enum rppx1_meas_chan)
227+ * @coeff_r: coefficient for the red Bayer sample or red color channel, Q1.7
228+ * @coeff_g_gr: coefficient for the green/red Bayer sample or green color channel, Q1.7
229+ * @coeff_b: coefficient for the blue Bayer sample or blue color channel, Q1.7
230+ * @coeff_gb: coefficient for the green/blue Bayer sample, unused in RGB mode, Q1.7
231+ * @reserved: padding
232+ */
233+struct rppx1_exm_params {
234+ struct v4l2_isp_params_block_header header;
235+ struct rppx1_window wnd;
236+ __u32 mode;
237+ __u32 last_line;
238+ __u8 channel_sel;
239+ __u8 coeff_r;
240+ __u8 coeff_g_gr;
241+ __u8 coeff_b;
242+ __u8 coeff_gb;
243+ __u8 reserved[3];
244+};
245+
152246 /**
153247 * RPPX1_PARAMS_MAX_SIZE - Maximum size of all RPP-X1 parameter blocks
154248 *
@@ -159,7 +253,9 @@ struct rppx1_awbg_params { · 4 unmodified lines
159253 (sizeof(struct rppx1_wbmeas_params) + \
160254 sizeof(struct rppx1_awbg_params) + \
161255 sizeof(struct rppx1_awbg_params) + \
162− sizeof(struct rppx1_awbg_params))
256+ sizeof(struct rppx1_awbg_params) + \
257+ sizeof(struct rppx1_exm_params) + \
258+ sizeof(struct rppx1_exm_params))
163259
164260 /* ---------------------------------------------------------------------------
165261 * Statistics Structures
@@ -176,9 +272,13 @@ struct rppx1_awbg_params { · 10 unmodified lines
176272 * NOTE: Only append to the enumeration as the numbers are uAPI.
177273 *
178274 * @RPPX1_STATS_BLOCK_TYPE_WBMEAS_POST: post-fusion white-balance measurement
275+ * @RPPX1_STATS_BLOCK_TYPE_EXM_PRE1: pre-fusion pipe1 exposure measurement
276+ * @RPPX1_STATS_BLOCK_TYPE_EXM_PRE2: pre-fusion pipe2 exposure measurement
179277 */
180278 enum rppx1_stats_block_type {
181279 RPPX1_STATS_BLOCK_TYPE_WBMEAS_POST,
280+ RPPX1_STATS_BLOCK_TYPE_EXM_PRE1,
281+ RPPX1_STATS_BLOCK_TYPE_EXM_PRE2,
182282 };
183283
184284 /**
@@ -198,6 +298,25 @@ struct rppx1_wbmeas_stats { · 13 unmodified lines
198298 __u32 mean_cr_or_r;
199299 };
200300
301+/* Exposure Measurement */
302+#define RPPX1_EXM_NUM_WIN 25
303+
304+/**
305+ * struct rppx1_exm_stats - Exposure measurement
306+ *
307+ * RPP-X1 exposure measurement calculates the mean value on 25 programmable
308+ * windows on the input picture.
309+ *
310+ * @header: block header (type = RPPX1_STATS_BLOCK_TYPE_EXM_PRE1)
311+ * @exp_mean: mean luminance values per block, up to 20-bit
312+ * @reserved: padding
313+ */
314+struct rppx1_exm_stats {
315+ struct v4l2_isp_block_header header;
316+ __u32 exp_mean[RPPX1_EXM_NUM_WIN];
317+ __u32 reserved;
318+};
319+
201320 /**
202321 * RPPX1_STATS_MAX_SIZE - Maximum size of all RPP-X1 statistics
203322 *
@@ -205,6 +324,8 @@ struct rppx1_wbmeas_stats { · 1 unmodified line
205324 * multiple pipes.
206325 */
207326 #define RPPX1_STATS_MAX_SIZE \
208− (sizeof(struct rppx1_wbmeas_stats))
327+ (sizeof(struct rppx1_wbmeas_stats) + \
328+ sizeof(struct rppx1_exm_stats) + \
329+ sizeof(struct rppx1_exm_stats))
209330
210331 #endif /* __UAPI_RPP_X1_CONFIG_H */