Message ID | 20240905225308.11267-9-laurent.pinchart@ideasonboard.com |
---|---|
State | New |
Headers | show |
Series | media: i2c: AR0144 camera sensor driver with companding support | expand |
On 06/09/2024 00:53, Laurent Pinchart wrote: > Companding refers to compression and expansion of pixel data to fit in a > smaller range. The control is named V4L2_CID_COMPANDING, and only > supports compression initially. > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > Changes since v1: > > - Rename V4L2_COMPANDING_ALAW to V4L2_COMPANDING_COMPRESS > - Document V4L2_COMPANDING_LINEAR and V4L2_COMPANDING_COMPRESS > --- > .../media/v4l/ext-ctrls-image-process.rst | 16 ++++++++++++++++ > drivers/media/v4l2-core/v4l2-ctrls-defs.c | 9 +++++++++ > include/uapi/linux/v4l2-controls.h | 5 +++++ > 3 files changed, 30 insertions(+) > > diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-image-process.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-image-process.rst > index b1c2ab2854af..d529b0a8cd41 100644 > --- a/Documentation/userspace-api/media/v4l/ext-ctrls-image-process.rst > +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-image-process.rst > @@ -55,3 +55,19 @@ Image Process Control IDs > control value divided by e.g. 0x100, meaning that to get no > digital gain the control value needs to be 0x100. The no-gain > configuration is also typically the default. > + > +``V4L2_CID_COMPANDING (menu)`` > + Companding refers to compression and expansion of pixel data to fit in a > + smaller range. > + > + > +.. tabularcolumns:: |p{5.7cm}|p{11.8cm}| > + > +.. flat-table:: > + :header-rows: 0 > + :stub-columns: 0 > + > + * - ``V4L2_COMPANDING_LINEAR`` > + - No companding. > + * - ``V4L2_COMPANDING_COMPRESS`` It's weird that this is called 'COMPRESS', > + - Compress the data using a device-specific curve. > diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c > index 1ea52011247a..841e415a88ae 100644 > --- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c > +++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c > @@ -611,6 +611,11 @@ const char * const *v4l2_ctrl_get_menu(u32 id) > "Cyclic", > NULL, > }; > + static const char * const companding[] = { > + "Linear", > + "A-Law", but it is called 'A-Law' here. I think the same name should be used for both as this is confusing. Regards, Hans > + NULL > + }; > > switch (id) { > case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: > @@ -750,6 +755,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id) > return camera_orientation; > case V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD_TYPE: > return intra_refresh_period_type; > + case V4L2_CID_COMPANDING: > + return companding; > default: > return NULL; > } > @@ -1164,6 +1171,7 @@ const char *v4l2_ctrl_get_name(u32 id) > case V4L2_CID_TEST_PATTERN: return "Test Pattern"; > case V4L2_CID_DEINTERLACING_MODE: return "Deinterlacing Mode"; > case V4L2_CID_DIGITAL_GAIN: return "Digital Gain"; > + case V4L2_CID_COMPANDING: return "Companding"; > > /* DV controls */ > /* Keep the order of the 'case's the same as in v4l2-controls.h! */ > @@ -1421,6 +1429,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, > case V4L2_CID_CAMERA_ORIENTATION: > case V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD_TYPE: > case V4L2_CID_HDR_SENSOR_MODE: > + case V4L2_CID_COMPANDING: > *type = V4L2_CTRL_TYPE_MENU; > break; > case V4L2_CID_LINK_FREQ: > diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h > index 974fd254e573..ca9e25f72886 100644 > --- a/include/uapi/linux/v4l2-controls.h > +++ b/include/uapi/linux/v4l2-controls.h > @@ -1225,6 +1225,11 @@ enum v4l2_jpeg_chroma_subsampling { > #define V4L2_CID_TEST_PATTERN (V4L2_CID_IMAGE_PROC_CLASS_BASE + 3) > #define V4L2_CID_DEINTERLACING_MODE (V4L2_CID_IMAGE_PROC_CLASS_BASE + 4) > #define V4L2_CID_DIGITAL_GAIN (V4L2_CID_IMAGE_PROC_CLASS_BASE + 5) > +#define V4L2_CID_COMPANDING (V4L2_CID_IMAGE_PROC_CLASS_BASE + 6) > +enum v4l2_companding { > + V4L2_COMPANDING_LINEAR = 0, > + V4L2_COMPANDING_COMPRESS = 1, > +}; > > /* DV-class control IDs defined by V4L2 */ > #define V4L2_CID_DV_CLASS_BASE (V4L2_CTRL_CLASS_DV | 0x900)
Hi Hans, On Fri, Sep 06, 2024 at 07:44:05AM +0200, Hans Verkuil wrote: > On 06/09/2024 00:53, Laurent Pinchart wrote: > > Companding refers to compression and expansion of pixel data to fit in a > > smaller range. The control is named V4L2_CID_COMPANDING, and only > > supports compression initially. > > > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > > --- > > Changes since v1: > > > > - Rename V4L2_COMPANDING_ALAW to V4L2_COMPANDING_COMPRESS > > - Document V4L2_COMPANDING_LINEAR and V4L2_COMPANDING_COMPRESS > > --- > > .../media/v4l/ext-ctrls-image-process.rst | 16 ++++++++++++++++ > > drivers/media/v4l2-core/v4l2-ctrls-defs.c | 9 +++++++++ > > include/uapi/linux/v4l2-controls.h | 5 +++++ > > 3 files changed, 30 insertions(+) > > > > diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-image-process.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-image-process.rst > > index b1c2ab2854af..d529b0a8cd41 100644 > > --- a/Documentation/userspace-api/media/v4l/ext-ctrls-image-process.rst > > +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-image-process.rst > > @@ -55,3 +55,19 @@ Image Process Control IDs > > control value divided by e.g. 0x100, meaning that to get no > > digital gain the control value needs to be 0x100. The no-gain > > configuration is also typically the default. > > + > > +``V4L2_CID_COMPANDING (menu)`` > > + Companding refers to compression and expansion of pixel data to fit in a > > + smaller range. > > + > > + > > +.. tabularcolumns:: |p{5.7cm}|p{11.8cm}| > > + > > +.. flat-table:: > > + :header-rows: 0 > > + :stub-columns: 0 > > + > > + * - ``V4L2_COMPANDING_LINEAR`` > > + - No companding. > > + * - ``V4L2_COMPANDING_COMPRESS`` > > It's weird that this is called 'COMPRESS', > > > + - Compress the data using a device-specific curve. > > diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c > > index 1ea52011247a..841e415a88ae 100644 > > --- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c > > +++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c > > @@ -611,6 +611,11 @@ const char * const *v4l2_ctrl_get_menu(u32 id) > > "Cyclic", > > NULL, > > }; > > + static const char * const companding[] = { > > + "Linear", > > + "A-Law", > > but it is called 'A-Law' here. I think the same name should be used for both > as this is confusing. I forgot to change this. I'll use "Compress". > > + NULL > > + }; > > > > switch (id) { > > case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: > > @@ -750,6 +755,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id) > > return camera_orientation; > > case V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD_TYPE: > > return intra_refresh_period_type; > > + case V4L2_CID_COMPANDING: > > + return companding; > > default: > > return NULL; > > } > > @@ -1164,6 +1171,7 @@ const char *v4l2_ctrl_get_name(u32 id) > > case V4L2_CID_TEST_PATTERN: return "Test Pattern"; > > case V4L2_CID_DEINTERLACING_MODE: return "Deinterlacing Mode"; > > case V4L2_CID_DIGITAL_GAIN: return "Digital Gain"; > > + case V4L2_CID_COMPANDING: return "Companding"; > > > > /* DV controls */ > > /* Keep the order of the 'case's the same as in v4l2-controls.h! */ > > @@ -1421,6 +1429,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, > > case V4L2_CID_CAMERA_ORIENTATION: > > case V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD_TYPE: > > case V4L2_CID_HDR_SENSOR_MODE: > > + case V4L2_CID_COMPANDING: > > *type = V4L2_CTRL_TYPE_MENU; > > break; > > case V4L2_CID_LINK_FREQ: > > diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h > > index 974fd254e573..ca9e25f72886 100644 > > --- a/include/uapi/linux/v4l2-controls.h > > +++ b/include/uapi/linux/v4l2-controls.h > > @@ -1225,6 +1225,11 @@ enum v4l2_jpeg_chroma_subsampling { > > #define V4L2_CID_TEST_PATTERN (V4L2_CID_IMAGE_PROC_CLASS_BASE + 3) > > #define V4L2_CID_DEINTERLACING_MODE (V4L2_CID_IMAGE_PROC_CLASS_BASE + 4) > > #define V4L2_CID_DIGITAL_GAIN (V4L2_CID_IMAGE_PROC_CLASS_BASE + 5) > > +#define V4L2_CID_COMPANDING (V4L2_CID_IMAGE_PROC_CLASS_BASE + 6) > > +enum v4l2_companding { > > + V4L2_COMPANDING_LINEAR = 0, > > + V4L2_COMPANDING_COMPRESS = 1, > > +}; > > > > /* DV-class control IDs defined by V4L2 */ > > #define V4L2_CID_DV_CLASS_BASE (V4L2_CTRL_CLASS_DV | 0x900)
diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-image-process.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-image-process.rst index b1c2ab2854af..d529b0a8cd41 100644 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-image-process.rst +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-image-process.rst @@ -55,3 +55,19 @@ Image Process Control IDs control value divided by e.g. 0x100, meaning that to get no digital gain the control value needs to be 0x100. The no-gain configuration is also typically the default. + +``V4L2_CID_COMPANDING (menu)`` + Companding refers to compression and expansion of pixel data to fit in a + smaller range. + + +.. tabularcolumns:: |p{5.7cm}|p{11.8cm}| + +.. flat-table:: + :header-rows: 0 + :stub-columns: 0 + + * - ``V4L2_COMPANDING_LINEAR`` + - No companding. + * - ``V4L2_COMPANDING_COMPRESS`` + - Compress the data using a device-specific curve. diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c index 1ea52011247a..841e415a88ae 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c @@ -611,6 +611,11 @@ const char * const *v4l2_ctrl_get_menu(u32 id) "Cyclic", NULL, }; + static const char * const companding[] = { + "Linear", + "A-Law", + NULL + }; switch (id) { case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: @@ -750,6 +755,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id) return camera_orientation; case V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD_TYPE: return intra_refresh_period_type; + case V4L2_CID_COMPANDING: + return companding; default: return NULL; } @@ -1164,6 +1171,7 @@ const char *v4l2_ctrl_get_name(u32 id) case V4L2_CID_TEST_PATTERN: return "Test Pattern"; case V4L2_CID_DEINTERLACING_MODE: return "Deinterlacing Mode"; case V4L2_CID_DIGITAL_GAIN: return "Digital Gain"; + case V4L2_CID_COMPANDING: return "Companding"; /* DV controls */ /* Keep the order of the 'case's the same as in v4l2-controls.h! */ @@ -1421,6 +1429,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, case V4L2_CID_CAMERA_ORIENTATION: case V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD_TYPE: case V4L2_CID_HDR_SENSOR_MODE: + case V4L2_CID_COMPANDING: *type = V4L2_CTRL_TYPE_MENU; break; case V4L2_CID_LINK_FREQ: diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index 974fd254e573..ca9e25f72886 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -1225,6 +1225,11 @@ enum v4l2_jpeg_chroma_subsampling { #define V4L2_CID_TEST_PATTERN (V4L2_CID_IMAGE_PROC_CLASS_BASE + 3) #define V4L2_CID_DEINTERLACING_MODE (V4L2_CID_IMAGE_PROC_CLASS_BASE + 4) #define V4L2_CID_DIGITAL_GAIN (V4L2_CID_IMAGE_PROC_CLASS_BASE + 5) +#define V4L2_CID_COMPANDING (V4L2_CID_IMAGE_PROC_CLASS_BASE + 6) +enum v4l2_companding { + V4L2_COMPANDING_LINEAR = 0, + V4L2_COMPANDING_COMPRESS = 1, +}; /* DV-class control IDs defined by V4L2 */ #define V4L2_CID_DV_CLASS_BASE (V4L2_CTRL_CLASS_DV | 0x900)
Companding refers to compression and expansion of pixel data to fit in a smaller range. The control is named V4L2_CID_COMPANDING, and only supports compression initially. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- Changes since v1: - Rename V4L2_COMPANDING_ALAW to V4L2_COMPANDING_COMPRESS - Document V4L2_COMPANDING_LINEAR and V4L2_COMPANDING_COMPRESS --- .../media/v4l/ext-ctrls-image-process.rst | 16 ++++++++++++++++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 9 +++++++++ include/uapi/linux/v4l2-controls.h | 5 +++++ 3 files changed, 30 insertions(+)