diff mbox series

[v2,02/10] media: Add Y012 video format

Message ID 93889cdefacaad260d978a8353066dd384a64609.1675230665.git.ming.qian@nxp.com (mailing list archive)
State New, archived
Headers show
Series media: imx-jpeg: Add support for 12 bit extended jpeg | expand

Commit Message

Ming Qian Feb. 1, 2023, 6:02 a.m. UTC
Y012 is a luma-only formats with 12-bits per pixel,
expanded to 16bits.
Data in the 12 high bits, zeros in the 4 low bits,
arranged in little endian order.

Signed-off-by: Ming Qian <ming.qian@nxp.com>
---
 .../userspace-api/media/v4l/pixfmt-yuv-luma.rst       | 11 +++++++++++
 drivers/media/v4l2-core/v4l2-ioctl.c                  |  1 +
 include/uapi/linux/videodev2.h                        |  1 +
 3 files changed, 13 insertions(+)

Comments

Nicolas Dufresne Feb. 10, 2023, 3:18 p.m. UTC | #1
Le mercredi 01 février 2023 à 14:02 +0800, Ming Qian a écrit :
> Y012 is a luma-only formats with 12-bits per pixel,
> expanded to 16bits.
> Data in the 12 high bits, zeros in the 4 low bits,
> arranged in little endian order.
> 
> Signed-off-by: Ming Qian <ming.qian@nxp.com>
> ---
>  .../userspace-api/media/v4l/pixfmt-yuv-luma.rst       | 11 +++++++++++
>  drivers/media/v4l2-core/v4l2-ioctl.c                  |  1 +
>  include/uapi/linux/videodev2.h                        |  1 +
>  3 files changed, 13 insertions(+)
> 
> diff --git a/Documentation/userspace-api/media/v4l/pixfmt-yuv-luma.rst b/Documentation/userspace-api/media/v4l/pixfmt-yuv-luma.rst
> index 6a387f9df3ba..3ffa29000238 100644
> --- a/Documentation/userspace-api/media/v4l/pixfmt-yuv-luma.rst
> +++ b/Documentation/userspace-api/media/v4l/pixfmt-yuv-luma.rst
> @@ -103,6 +103,17 @@ are often referred to as greyscale formats.
>        - ...
>        - ...
>  
> +    * .. _V4L2-PIX-FMT-Y012:

Why the 0, can't this be name Y12 (just like Y14) ?

> +
> +      - ``V4L2_PIX_FMT_Y012``
> +      - 'Y012'
> +
> +      - Y'\ :sub:`0`\ [3:0] `0000`
> +      - Y'\ :sub:`0`\ [11:4]
> +      - ...
> +      - ...
> +      - ...
> +
>      * .. _V4L2-PIX-FMT-Y14:
>  
>        - ``V4L2_PIX_FMT_Y14``
> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
> index 067dbdd0a9ef..0ee730aa6cc7 100644
> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> @@ -1303,6 +1303,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
>  	case V4L2_PIX_FMT_Y6:		descr = "6-bit Greyscale"; break;
>  	case V4L2_PIX_FMT_Y10:		descr = "10-bit Greyscale"; break;
>  	case V4L2_PIX_FMT_Y12:		descr = "12-bit Greyscale"; break;
> +	case V4L2_PIX_FMT_Y012:		descr = "12-bit Greyscale"; break;
>  	case V4L2_PIX_FMT_Y14:		descr = "14-bit Greyscale"; break;
>  	case V4L2_PIX_FMT_Y16:		descr = "16-bit Greyscale"; break;
>  	case V4L2_PIX_FMT_Y16_BE:	descr = "16-bit Greyscale BE"; break;
> diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
> index 5448aa3b7858..3d8f89bff33c 100644
> --- a/include/uapi/linux/videodev2.h
> +++ b/include/uapi/linux/videodev2.h
> @@ -583,6 +583,7 @@ struct v4l2_pix_format {
>  #define V4L2_PIX_FMT_Y6      v4l2_fourcc('Y', '0', '6', ' ') /*  6  Greyscale     */
>  #define V4L2_PIX_FMT_Y10     v4l2_fourcc('Y', '1', '0', ' ') /* 10  Greyscale     */
>  #define V4L2_PIX_FMT_Y12     v4l2_fourcc('Y', '1', '2', ' ') /* 12  Greyscale     */
> +#define V4L2_PIX_FMT_Y012    v4l2_fourcc('Y', '0', '1', '2') /* 12  Greyscale     */
>  #define V4L2_PIX_FMT_Y14     v4l2_fourcc('Y', '1', '4', ' ') /* 14  Greyscale     */
>  #define V4L2_PIX_FMT_Y16     v4l2_fourcc('Y', '1', '6', ' ') /* 16  Greyscale     */
>  #define V4L2_PIX_FMT_Y16_BE  v4l2_fourcc_be('Y', '1', '6', ' ') /* 16  Greyscale BE  */
Ming Qian Feb. 13, 2023, 9:22 a.m. UTC | #2
>From: Nicolas Dufresne <nicolas@ndufresne.ca>
>Sent: 2023年2月10日 23:18
>To: Ming Qian <ming.qian@nxp.com>; mchehab@kernel.org; Mirela Rabulea
>(OSS) <mirela.rabulea@oss.nxp.com>; hverkuil-cisco@xs4all.nl
>Cc: shawnguo@kernel.org; s.hauer@pengutronix.de; kernel@pengutronix.de;
>festevam@gmail.com; X.H. Bao <xiahong.bao@nxp.com>; dl-linux-imx <linux-
>imx@nxp.com>; linux-media@vger.kernel.org; linux-kernel@vger.kernel.org;
>devicetree@vger.kernel.org; linux-arm-kernel@lists.infradead.org
>Subject: [EXT] Re: [PATCH v2 02/10] media: Add Y012 video format
>
>Caution: EXT Email
>
>Le mercredi 01 février 2023 à 14:02 +0800, Ming Qian a écrit :
>> Y012 is a luma-only formats with 12-bits per pixel, expanded to
>> 16bits.
>> Data in the 12 high bits, zeros in the 4 low bits, arranged in little
>> endian order.
>>
>> Signed-off-by: Ming Qian <ming.qian@nxp.com>
>> ---
>>  .../userspace-api/media/v4l/pixfmt-yuv-luma.rst       | 11 +++++++++++
>>  drivers/media/v4l2-core/v4l2-ioctl.c                  |  1 +
>>  include/uapi/linux/videodev2.h                        |  1 +
>>  3 files changed, 13 insertions(+)
>>
>> diff --git a/Documentation/userspace-api/media/v4l/pixfmt-yuv-luma.rst
>> b/Documentation/userspace-api/media/v4l/pixfmt-yuv-luma.rst
>> index 6a387f9df3ba..3ffa29000238 100644
>> --- a/Documentation/userspace-api/media/v4l/pixfmt-yuv-luma.rst
>> +++ b/Documentation/userspace-api/media/v4l/pixfmt-yuv-luma.rst
>> @@ -103,6 +103,17 @@ are often referred to as greyscale formats.
>>        - ...
>>        - ...
>>
>> +    * .. _V4L2-PIX-FMT-Y012:
>
>Why the 0, can't this be name Y12 (just like Y14) ?
>

Hi Nicolas,
    As the V4L2_PIX_FMT_Y12 is defined, but it's data is in the 12 low bits, zeros in the high bits.
    Here I want to place the 12 bits data in the high bits, with zeros in the 4 low bits.
    So I add 0 before 12, I want to say that the low bits are padding data 0.
   
    Or do you have a better suggestion?

Ming

>> +
>> +      - ``V4L2_PIX_FMT_Y012``
>> +      - 'Y012'
>> +
>> +      - Y'\ :sub:`0`\ [3:0] `0000`
>> +      - Y'\ :sub:`0`\ [11:4]
>> +      - ...
>> +      - ...
>> +      - ...
>> +
>>      * .. _V4L2-PIX-FMT-Y14:
>>
>>        - ``V4L2_PIX_FMT_Y14``
>> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c
>> b/drivers/media/v4l2-core/v4l2-ioctl.c
>> index 067dbdd0a9ef..0ee730aa6cc7 100644
>> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
>> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
>> @@ -1303,6 +1303,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc
>*fmt)
>>       case V4L2_PIX_FMT_Y6:           descr = "6-bit Greyscale"; break;
>>       case V4L2_PIX_FMT_Y10:          descr = "10-bit Greyscale"; break;
>>       case V4L2_PIX_FMT_Y12:          descr = "12-bit Greyscale"; break;
>> +     case V4L2_PIX_FMT_Y012:         descr = "12-bit Greyscale"; break;
>>       case V4L2_PIX_FMT_Y14:          descr = "14-bit Greyscale"; break;
>>       case V4L2_PIX_FMT_Y16:          descr = "16-bit Greyscale"; break;
>>       case V4L2_PIX_FMT_Y16_BE:       descr = "16-bit Greyscale BE"; break;
>> diff --git a/include/uapi/linux/videodev2.h
>> b/include/uapi/linux/videodev2.h index 5448aa3b7858..3d8f89bff33c
>> 100644
>> --- a/include/uapi/linux/videodev2.h
>> +++ b/include/uapi/linux/videodev2.h
>> @@ -583,6 +583,7 @@ struct v4l2_pix_format {
>>  #define V4L2_PIX_FMT_Y6      v4l2_fourcc('Y', '0', '6', ' ') /*  6  Greyscale     */
>>  #define V4L2_PIX_FMT_Y10     v4l2_fourcc('Y', '1', '0', ' ') /* 10  Greyscale
>*/
>>  #define V4L2_PIX_FMT_Y12     v4l2_fourcc('Y', '1', '2', ' ') /* 12  Greyscale
>*/
>> +#define V4L2_PIX_FMT_Y012    v4l2_fourcc('Y', '0', '1', '2') /* 12  Greyscale
>*/
>>  #define V4L2_PIX_FMT_Y14     v4l2_fourcc('Y', '1', '4', ' ') /* 14  Greyscale
>*/
>>  #define V4L2_PIX_FMT_Y16     v4l2_fourcc('Y', '1', '6', ' ') /* 16  Greyscale
>*/
>>  #define V4L2_PIX_FMT_Y16_BE  v4l2_fourcc_be('Y', '1', '6', ' ') /* 16
>> Greyscale BE  */
Nicolas Dufresne Feb. 13, 2023, 4:38 p.m. UTC | #3
Le lundi 13 février 2023 à 09:22 +0000, Ming Qian a écrit :
> > From: Nicolas Dufresne <nicolas@ndufresne.ca>
> > Sent: 2023年2月10日 23:18
> > To: Ming Qian <ming.qian@nxp.com>; mchehab@kernel.org; Mirela Rabulea
> > (OSS) <mirela.rabulea@oss.nxp.com>; hverkuil-cisco@xs4all.nl
> > Cc: shawnguo@kernel.org; s.hauer@pengutronix.de; kernel@pengutronix.de;
> > festevam@gmail.com; X.H. Bao <xiahong.bao@nxp.com>; dl-linux-imx <linux-
> > imx@nxp.com>; linux-media@vger.kernel.org; linux-kernel@vger.kernel.org;
> > devicetree@vger.kernel.org; linux-arm-kernel@lists.infradead.org
> > Subject: [EXT] Re: [PATCH v2 02/10] media: Add Y012 video format
> > 
> > Caution: EXT Email
> > 
> > Le mercredi 01 février 2023 à 14:02 +0800, Ming Qian a écrit :
> > > Y012 is a luma-only formats with 12-bits per pixel, expanded to
> > > 16bits.
> > > Data in the 12 high bits, zeros in the 4 low bits, arranged in little
> > > endian order.
> > > 
> > > Signed-off-by: Ming Qian <ming.qian@nxp.com>
> > > ---
> > >  .../userspace-api/media/v4l/pixfmt-yuv-luma.rst       | 11 +++++++++++
> > >  drivers/media/v4l2-core/v4l2-ioctl.c                  |  1 +
> > >  include/uapi/linux/videodev2.h                        |  1 +
> > >  3 files changed, 13 insertions(+)
> > > 
> > > diff --git a/Documentation/userspace-api/media/v4l/pixfmt-yuv-luma.rst
> > > b/Documentation/userspace-api/media/v4l/pixfmt-yuv-luma.rst
> > > index 6a387f9df3ba..3ffa29000238 100644
> > > --- a/Documentation/userspace-api/media/v4l/pixfmt-yuv-luma.rst
> > > +++ b/Documentation/userspace-api/media/v4l/pixfmt-yuv-luma.rst
> > > @@ -103,6 +103,17 @@ are often referred to as greyscale formats.
> > >        - ...
> > >        - ...
> > > 
> > > +    * .. _V4L2-PIX-FMT-Y012:
> > 
> > Why the 0, can't this be name Y12 (just like Y14) ?
> > 
> 
> Hi Nicolas,
>     As the V4L2_PIX_FMT_Y12 is defined, but it's data is in the 12 low bits,
> zeros in the high bits.
>     Here I want to place the 12 bits data in the high bits, with zeros in the
> 4 low bits.
>     So I add 0 before 12, I want to say that the low bits are padding data 0.
>    
>     Or do you have a better suggestion?

I see, I had missed this aspect. I think in this context, it would be fair
naming. Maybe drop a note in the doc saying just that:

"In contrast to V4L2_PIX_FMT_Y12 format, which have its padding located in the
most significant bits of the 16 bit word".

Or something similar.,
Nicolas

> 
> Ming
> 
> > > +
> > > +      - ``V4L2_PIX_FMT_Y012``
> > > +      - 'Y012'
> > > +
> > > +      - Y'\ :sub:`0`\ [3:0] `0000`
> > > +      - Y'\ :sub:`0`\ [11:4]
> > > +      - ...
> > > +      - ...
> > > +      - ...
> > > +
> > >      * .. _V4L2-PIX-FMT-Y14:
> > > 
> > >        - ``V4L2_PIX_FMT_Y14``
> > > diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c
> > > b/drivers/media/v4l2-core/v4l2-ioctl.c
> > > index 067dbdd0a9ef..0ee730aa6cc7 100644
> > > --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> > > +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> > > @@ -1303,6 +1303,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc
> > *fmt)
> > >       case V4L2_PIX_FMT_Y6:           descr = "6-bit Greyscale"; break;
> > >       case V4L2_PIX_FMT_Y10:          descr = "10-bit Greyscale"; break;
> > >       case V4L2_PIX_FMT_Y12:          descr = "12-bit Greyscale"; break;
> > > +     case V4L2_PIX_FMT_Y012:         descr = "12-bit Greyscale"; break;
> > >       case V4L2_PIX_FMT_Y14:          descr = "14-bit Greyscale"; break;
> > >       case V4L2_PIX_FMT_Y16:          descr = "16-bit Greyscale"; break;
> > >       case V4L2_PIX_FMT_Y16_BE:       descr = "16-bit Greyscale BE";
> > > break;
> > > diff --git a/include/uapi/linux/videodev2.h
> > > b/include/uapi/linux/videodev2.h index 5448aa3b7858..3d8f89bff33c
> > > 100644
> > > --- a/include/uapi/linux/videodev2.h
> > > +++ b/include/uapi/linux/videodev2.h
> > > @@ -583,6 +583,7 @@ struct v4l2_pix_format {
> > >  #define V4L2_PIX_FMT_Y6      v4l2_fourcc('Y', '0', '6', ' ') /*  6 
> > > Greyscale     */
> > >  #define V4L2_PIX_FMT_Y10     v4l2_fourcc('Y', '1', '0', ' ') /* 10 
> > > Greyscale
> > */
> > >  #define V4L2_PIX_FMT_Y12     v4l2_fourcc('Y', '1', '2', ' ') /* 12 
> > > Greyscale
> > */
> > > +#define V4L2_PIX_FMT_Y012    v4l2_fourcc('Y', '0', '1', '2') /* 12 
> > > Greyscale
> > */
> > >  #define V4L2_PIX_FMT_Y14     v4l2_fourcc('Y', '1', '4', ' ') /* 14 
> > > Greyscale
> > */
> > >  #define V4L2_PIX_FMT_Y16     v4l2_fourcc('Y', '1', '6', ' ') /* 16 
> > > Greyscale
> > */
> > >  #define V4L2_PIX_FMT_Y16_BE  v4l2_fourcc_be('Y', '1', '6', ' ') /* 16
> > > Greyscale BE  */
>
Ming Qian Feb. 14, 2023, 1:51 a.m. UTC | #4
>From: Nicolas Dufresne <nicolas@ndufresne.ca>
>Sent: 2023年2月14日 0:39
>To: Ming Qian <ming.qian@nxp.com>; mchehab@kernel.org; Mirela Rabulea
>(OSS) <mirela.rabulea@oss.nxp.com>; hverkuil-cisco@xs4all.nl
>Cc: shawnguo@kernel.org; s.hauer@pengutronix.de; kernel@pengutronix.de;
>festevam@gmail.com; X.H. Bao <xiahong.bao@nxp.com>; dl-linux-imx <linux-
>imx@nxp.com>; linux-media@vger.kernel.org; linux-kernel@vger.kernel.org;
>devicetree@vger.kernel.org; linux-arm-kernel@lists.infradead.org
>Subject: Re: [EXT] Re: [PATCH v2 02/10] media: Add Y012 video format
>
>Caution: EXT Email
>
>Le lundi 13 février 2023 à 09:22 +0000, Ming Qian a écrit :
>> > From: Nicolas Dufresne <nicolas@ndufresne.ca>
>> > Sent: 2023年2月10日 23:18
>> > To: Ming Qian <ming.qian@nxp.com>; mchehab@kernel.org; Mirela
>> > Rabulea
>> > (OSS) <mirela.rabulea@oss.nxp.com>; hverkuil-cisco@xs4all.nl
>> > Cc: shawnguo@kernel.org; s.hauer@pengutronix.de;
>> > kernel@pengutronix.de; festevam@gmail.com; X.H. Bao
>> > <xiahong.bao@nxp.com>; dl-linux-imx <linux- imx@nxp.com>;
>> > linux-media@vger.kernel.org; linux-kernel@vger.kernel.org;
>> > devicetree@vger.kernel.org; linux-arm-kernel@lists.infradead.org
>> > Subject: [EXT] Re: [PATCH v2 02/10] media: Add Y012 video format
>> >
>> > Caution: EXT Email
>> >
>> > Le mercredi 01 février 2023 à 14:02 +0800, Ming Qian a écrit :
>> > > Y012 is a luma-only formats with 12-bits per pixel, expanded to
>> > > 16bits.
>> > > Data in the 12 high bits, zeros in the 4 low bits, arranged in
>> > > little endian order.
>> > >
>> > > Signed-off-by: Ming Qian <ming.qian@nxp.com>
>> > > ---
>> > >  .../userspace-api/media/v4l/pixfmt-yuv-luma.rst       | 11 +++++++++++
>> > >  drivers/media/v4l2-core/v4l2-ioctl.c                  |  1 +
>> > >  include/uapi/linux/videodev2.h                        |  1 +
>> > >  3 files changed, 13 insertions(+)
>> > >
>> > > diff --git
>> > > a/Documentation/userspace-api/media/v4l/pixfmt-yuv-luma.rst
>> > > b/Documentation/userspace-api/media/v4l/pixfmt-yuv-luma.rst
>> > > index 6a387f9df3ba..3ffa29000238 100644
>> > > --- a/Documentation/userspace-api/media/v4l/pixfmt-yuv-luma.rst
>> > > +++ b/Documentation/userspace-api/media/v4l/pixfmt-yuv-luma.rst
>> > > @@ -103,6 +103,17 @@ are often referred to as greyscale formats.
>> > >        - ...
>> > >        - ...
>> > >
>> > > +    * .. _V4L2-PIX-FMT-Y012:
>> >
>> > Why the 0, can't this be name Y12 (just like Y14) ?
>> >
>>
>> Hi Nicolas,
>>     As the V4L2_PIX_FMT_Y12 is defined, but it's data is in the 12 low
>> bits, zeros in the high bits.
>>     Here I want to place the 12 bits data in the high bits, with zeros
>> in the
>> 4 low bits.
>>     So I add 0 before 12, I want to say that the low bits are padding data 0.
>>
>>     Or do you have a better suggestion?
>
>I see, I had missed this aspect. I think in this context, it would be fair naming.
>Maybe drop a note in the doc saying just that:
>
>"In contrast to V4L2_PIX_FMT_Y12 format, which have its padding located in
>the most significant bits of the 16 bit word".
>
>Or something similar.,
>Nicolas

Hi Nicolas,
    Thanks very much, I'll include the description in v3 patch

>
>>
>> Ming
>>
>> > > +
>> > > +      - ``V4L2_PIX_FMT_Y012``
>> > > +      - 'Y012'
>> > > +
>> > > +      - Y'\ :sub:`0`\ [3:0] `0000`
>> > > +      - Y'\ :sub:`0`\ [11:4]
>> > > +      - ...
>> > > +      - ...
>> > > +      - ...
>> > > +
>> > >      * .. _V4L2-PIX-FMT-Y14:
>> > >
>> > >        - ``V4L2_PIX_FMT_Y14``
>> > > diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c
>> > > b/drivers/media/v4l2-core/v4l2-ioctl.c
>> > > index 067dbdd0a9ef..0ee730aa6cc7 100644
>> > > --- a/drivers/media/v4l2-core/v4l2-ioctl.c
>> > > +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
>> > > @@ -1303,6 +1303,7 @@ static void v4l_fill_fmtdesc(struct
>> > > v4l2_fmtdesc
>> > *fmt)
>> > >       case V4L2_PIX_FMT_Y6:           descr = "6-bit Greyscale"; break;
>> > >       case V4L2_PIX_FMT_Y10:          descr = "10-bit Greyscale"; break;
>> > >       case V4L2_PIX_FMT_Y12:          descr = "12-bit Greyscale"; break;
>> > > +     case V4L2_PIX_FMT_Y012:         descr = "12-bit Greyscale"; break;
>> > >       case V4L2_PIX_FMT_Y14:          descr = "14-bit Greyscale"; break;
>> > >       case V4L2_PIX_FMT_Y16:          descr = "16-bit Greyscale"; break;
>> > >       case V4L2_PIX_FMT_Y16_BE:       descr = "16-bit Greyscale BE";
>> > > break;
>> > > diff --git a/include/uapi/linux/videodev2.h
>> > > b/include/uapi/linux/videodev2.h index 5448aa3b7858..3d8f89bff33c
>> > > 100644
>> > > --- a/include/uapi/linux/videodev2.h
>> > > +++ b/include/uapi/linux/videodev2.h
>> > > @@ -583,6 +583,7 @@ struct v4l2_pix_format {
>> > >  #define V4L2_PIX_FMT_Y6      v4l2_fourcc('Y', '0', '6', ' ') /*  6
>> > > Greyscale     */
>> > >  #define V4L2_PIX_FMT_Y10     v4l2_fourcc('Y', '1', '0', ' ') /* 10
>> > > Greyscale
>> > */
>> > >  #define V4L2_PIX_FMT_Y12     v4l2_fourcc('Y', '1', '2', ' ') /* 12
>> > > Greyscale
>> > */
>> > > +#define V4L2_PIX_FMT_Y012    v4l2_fourcc('Y', '0', '1', '2') /* 12
>> > > Greyscale
>> > */
>> > >  #define V4L2_PIX_FMT_Y14     v4l2_fourcc('Y', '1', '4', ' ') /* 14
>> > > Greyscale
>> > */
>> > >  #define V4L2_PIX_FMT_Y16     v4l2_fourcc('Y', '1', '6', ' ') /* 16
>> > > Greyscale
>> > */
>> > >  #define V4L2_PIX_FMT_Y16_BE  v4l2_fourcc_be('Y', '1', '6', ' ')
>> > > /* 16 Greyscale BE  */
>>
diff mbox series

Patch

diff --git a/Documentation/userspace-api/media/v4l/pixfmt-yuv-luma.rst b/Documentation/userspace-api/media/v4l/pixfmt-yuv-luma.rst
index 6a387f9df3ba..3ffa29000238 100644
--- a/Documentation/userspace-api/media/v4l/pixfmt-yuv-luma.rst
+++ b/Documentation/userspace-api/media/v4l/pixfmt-yuv-luma.rst
@@ -103,6 +103,17 @@  are often referred to as greyscale formats.
       - ...
       - ...
 
+    * .. _V4L2-PIX-FMT-Y012:
+
+      - ``V4L2_PIX_FMT_Y012``
+      - 'Y012'
+
+      - Y'\ :sub:`0`\ [3:0] `0000`
+      - Y'\ :sub:`0`\ [11:4]
+      - ...
+      - ...
+      - ...
+
     * .. _V4L2-PIX-FMT-Y14:
 
       - ``V4L2_PIX_FMT_Y14``
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 067dbdd0a9ef..0ee730aa6cc7 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1303,6 +1303,7 @@  static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
 	case V4L2_PIX_FMT_Y6:		descr = "6-bit Greyscale"; break;
 	case V4L2_PIX_FMT_Y10:		descr = "10-bit Greyscale"; break;
 	case V4L2_PIX_FMT_Y12:		descr = "12-bit Greyscale"; break;
+	case V4L2_PIX_FMT_Y012:		descr = "12-bit Greyscale"; break;
 	case V4L2_PIX_FMT_Y14:		descr = "14-bit Greyscale"; break;
 	case V4L2_PIX_FMT_Y16:		descr = "16-bit Greyscale"; break;
 	case V4L2_PIX_FMT_Y16_BE:	descr = "16-bit Greyscale BE"; break;
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 5448aa3b7858..3d8f89bff33c 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -583,6 +583,7 @@  struct v4l2_pix_format {
 #define V4L2_PIX_FMT_Y6      v4l2_fourcc('Y', '0', '6', ' ') /*  6  Greyscale     */
 #define V4L2_PIX_FMT_Y10     v4l2_fourcc('Y', '1', '0', ' ') /* 10  Greyscale     */
 #define V4L2_PIX_FMT_Y12     v4l2_fourcc('Y', '1', '2', ' ') /* 12  Greyscale     */
+#define V4L2_PIX_FMT_Y012    v4l2_fourcc('Y', '0', '1', '2') /* 12  Greyscale     */
 #define V4L2_PIX_FMT_Y14     v4l2_fourcc('Y', '1', '4', ' ') /* 14  Greyscale     */
 #define V4L2_PIX_FMT_Y16     v4l2_fourcc('Y', '1', '6', ' ') /* 16  Greyscale     */
 #define V4L2_PIX_FMT_Y16_BE  v4l2_fourcc_be('Y', '1', '6', ' ') /* 16  Greyscale BE  */