v4l: Add Genicam 12-bit bayer packed formats
Subsystems (3)
PATCH 1/2 v4l: Add Genicam 12-bit bayer packed formats
These formats are compressed 12-bit raw bayer formats with four different pixel orders. They are similar to 10-bit bayer formats 'IPU3'. The naming and pixel structure follow
the Genicam Pixel Format Naming Convention (PFNC).
--- .../media/uapi/v4l/pixfmt-pfnc-bayerrg12p.rst | 61 +++++++++++++++++++ Documentation/media/uapi/v4l/pixfmt-rgb.rst | 1 + drivers/media/v4l2-core/v4l2-ioctl.c | 4 ++ include/uapi/linux/videodev2.h | 7 +++ 4 files changed, 73 insertions(+) create mode 100644 Documentation/media/uapi/v4l/pixfmt-pfnc-bayerrg12p.rst
Documentation/media/uapi/v4l/pixfmt-pfnc-bayerrg12p.rst new file +61 -0
@@ -0,0 +1,61 @@ +.. -*- coding: utf-8; mode: rst -*- + +.. _v4l2-pix-fmt-pfnc-bayergr12p: +.. _v4l2-pix-fmt-pfnc-bayerrg12p: +.. _v4l2-pix-fmt-pfnc-bayerbg12p: +.. _v4l2-pix-fmt-pfnc-bayergb12p: + +********************************************************************************************************************************************************** +V4L2_PIX_FMT_PFNC_BAYERBG12P ('BGCp'), V4L2_PIX_FMT_PFNC_BAYERGB12P ('GBCp'), V4L2_PIX_FMT_PFNC_BAYERGR12P ('GRCp'), V4L2_PIX_FMT_PFNC_BAYERRG12P ('RGCp') +********************************************************************************************************************************************************** + +12-bit Bayer formats + +Description +=========== + +These four pixel formats are used by industrial cameras, often in conjunction +with UsbVision (see https://www.visiononline.org/userAssets/aiaUploads/file/USB3_Vision_Specification_v1-0-1.pdf). + +The naming is in accordance to the Genicam Pixel Format Naming Convention +(see https://www.emva.org/wp-content/uploads/GenICam_PFNC_2_3.pdf). + +They are raw sRGB / Bayer formats with 12 bits +per sample with 3 bytes for every 2 pixels. + +The format is little endian. + +In other respects this format is similar to :ref:`v4l2-pix-fmt-ipu3-sbggr10`. +Below is an example of a small image in V4L2_PIX_FMT_PFNC_BAYERBG12P format. + +**Byte Order.** +Each cell is one byte. + +.. tabularcolumns:: |p{0.8cm}|p{4.0cm}|p{4.0cm}|p{4.0cm}|p{4.0cm}| + +.. flat-table:: + + * - start + 0: + - B\ :sub:`00low` + - G\ :sub:`01low`\ (bits 7--4) + B\ :sub:`00high`\ (bits 0--3) + - G\ :sub:`01high`\ + + * - start + 6: + - G\ :sub:`02low` + - R\ :sub:`03low`\ (bits 7--4) + G\ :sub:`02high`\ (bits 0--3) + - R\ :sub:`03high` + + * - start + 12: + - B\ :sub:`04low` + - G\ :sub:`05low`\ (bits 7--4) + B\ :sub:`04high`\ (bits 0--3) + - G\ :sub:`05high` + + * - start + 24: + - G\ :sub:`06low` + - R\ :sub:`07low`\ (bits 7--4) + G\ :sub:`06high`\ (bits 0--3) + - R\ :sub:`07high` +
Documentation/media/uapi/v4l/pixfmt-rgb.rst +1 -0
@@ -26,5 +26,6 @@ RGB Formats pixfmt-srggb10-ipu3 pixfmt-srggb12 pixfmt-srggb12p + pixfmt-pfnc-bayerrg12p pixfmt-srggb14p pixfmt-srggb16
drivers/media/v4l2-core/v4l2-ioctl.c +4 -0
@@ -1275,6 +1275,10 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)case V4L2_PIX_FMT_SGBRG12 : descr ="12-bit Bayer GBGB/RGRG" ;break ;case V4L2_PIX_FMT_SGRBG12 : descr ="12-bit Bayer GRGR/BGBG" ;break ;case V4L2_PIX_FMT_SRGGB12 : descr ="12-bit Bayer RGRG/GBGB" ;break ; +case V4L2_PIX_FMT_PFNC_BAYERBG12P : descr ="12-bit Bayer BGBG/GRGR PFNC Packed" ;break ; +case V4L2_PIX_FMT_PFNC_BAYERGB12P : descr ="12-bit Bayer GBGB/RGRG PFNC Packed" ;break ; +case V4L2_PIX_FMT_PFNC_BAYERGR12P : descr ="12-bit Bayer GRGR/BGBG PFNC Packed" ;break ; +case V4L2_PIX_FMT_PFNC_BAYERRG12P : descr ="12-bit Bayer RGRG/GBGB PFNC Packed" ;break ;case V4L2_PIX_FMT_SBGGR12P : descr ="12-bit Bayer BGBG/GRGR Packed" ;break ;case V4L2_PIX_FMT_SGBRG12P : descr ="12-bit Bayer GBGB/RGRG Packed" ;break ;case V4L2_PIX_FMT_SGRBG12P : descr ="12-bit Bayer GRGR/BGBG Packed" ;break ;
include/uapi/linux/videodev2.h +7 -0
@@ -646,6 +646,13 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_SGBRG12 v4l2_fourcc('G', 'B', '1', '2')/* 12 GBGB.. RGRG.. */ #define V4L2_PIX_FMT_SGRBG12 v4l2_fourcc('B', 'A', '1', '2')/* 12 GRGR.. BGBG.. */ #define V4L2_PIX_FMT_SRGGB12 v4l2_fourcc('R', 'G', '1', '2')/* 12 RGRG.. GBGB.. */ + +/* 12bit raw bayer simple packed, 6 bytes for every 4 pixels */ +#define V4L2_PIX_FMT_PFNC_BAYERBG12P v4l2_fourcc('B', 'G', 'C', 'p') +#define V4L2_PIX_FMT_PFNC_BAYERGB12P v4l2_fourcc('G', 'B', 'C', 'p') +#define V4L2_PIX_FMT_PFNC_BAYERGR12P v4l2_fourcc('G', 'R', 'C', 'p') +#define V4L2_PIX_FMT_PFNC_BAYERRG12P v4l2_fourcc('R', 'G', 'C', 'p') +/* 12bit raw bayer packed, 6 bytes for every 4 pixels */ #define V4L2_PIX_FMT_SBGGR12P v4l2_fourcc('p', 'B', 'C', 'C')#define V4L2_PIX_FMT_SGBRG12P v4l2_fourcc('p', 'G', 'C', 'C')
--
2.20.1
PATCH 2/2 uvc: Add Genicam 12-bit bayer packed formats
These formats are compressed 12-bit raw bayer formats with four different pixel orders. They are similar to 10-bit bayer formats 'IPU3'. The naming and pixel structure follow
the Genicam Pixel Format Naming Convention (PFNC).
The added GUIDs are used by USB-3.0 cameras produced by The Imaging Source.
--- drivers/media/usb/uvc/uvc_driver.c | 20 ++++++++++++++++++++ drivers/media/usb/uvc/uvcvideo.h | 12 ++++++++++++ 2 files changed, 32 insertions(+)
drivers/media/usb/uvc/uvc_driver.c +20 -0
@@ -179,6 +179,26 @@ static struct uvc_format_desc uvc_fmts[] = { .guid = UVC_GUID_FORMAT_RW10, .fcc = V4L2_PIX_FMT_SRGGB10P, }, + { + .name = "Bayer 12-bit PFNC packed (BayerBG12P)", + .guid = UVC_GUID_FORMAT_TIS_BAYERBG12P, + .fcc = V4L2_PIX_FMT_PFNC_BAYERBG12P, + }, + { + .name = "Bayer 12-bit PFNC packed (BayerGB12P)", + .guid = UVC_GUID_FORMAT_TIS_BAYERGB12P, + .fcc = V4L2_PIX_FMT_PFNC_BAYERGB12P, + }, + { + .name = "Bayer 12-bit PFNC packed (BayerRG12P)", + .guid = UVC_GUID_FORMAT_TIS_BAYERRG12P, + .fcc = V4L2_PIX_FMT_PFNC_BAYERRG12P, + }, + { + .name = "Bayer 12-bit PFNC packed (BayerGR12P)", + .guid = UVC_GUID_FORMAT_TIS_BAYERGR12P, + .fcc = V4L2_PIX_FMT_PFNC_BAYERGR12P, + }, { .name = "Bayer 16-bit (SBGGR16)", .guid = UVC_GUID_FORMAT_BG16,
drivers/media/usb/uvc/uvcvideo.h +12 -0
@@ -108,6 +108,18 @@#define UVC_GUID_FORMAT_RGGB \ { 'R', 'G', 'G', 'B', 0x00, 0x00, 0x10, 0x00, \ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} +#define UVC_GUID_FORMAT_TIS_BAYERBG12P \ + { 'B', 'G', 'C', 'p', 0x00, 0x00, 0x10, 0x00, \ + 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} +#define UVC_GUID_FORMAT_TIS_BAYERGB12P \ + { 'G', 'B', 'C', 'p', 0x00, 0x00, 0x10, 0x00, \ + 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} +#define UVC_GUID_FORMAT_TIS_BAYERRG12P \ + { 'R', 'G', 'C', 'p', 0x00, 0x00, 0x10, 0x00, \ + 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} +#define UVC_GUID_FORMAT_TIS_BAYERGR12P \ + { 'G', 'R', 'C', 'p', 0x00, 0x00, 0x10, 0x00, \ + 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}#define UVC_GUID_FORMAT_BG16 \ { 'B', 'G', '1', '6', 0x00, 0x00, 0x10, 0x00, \ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
Signature · 1 line
2.20.1
Hi Edgar,
Quoted 4 lines · Edgar Thier
These formats are compressed 12-bit raw bayer formats with four different pixel orders. They are similar to 10-bit bayer formats 'IPU3'. The naming and pixel structure follow
the Genicam Pixel Format Naming Convention (PFNC).
Genicam appears to define a naming scheme for most formats V4L2 already supports. I'm not very eager to embark toward that route without evaluating other possibilities. The fact is that the V4L2 naming of Bayer formats is somewhat odd, but I don't think adopting Genicam PFNC as such is the obvious solution. I'd also expect the new naming convention to be used on existing formats, too, but that conversion should be done at the same time than adopting that convention for new formats.
How about calling it "Linear Packed" as was suggested on #v4l?
Quoted 121 lines
Signed-off-by Edgar Thier <[email protected]>--- .../media/uapi/v4l/pixfmt-pfnc-bayerrg12p.rst | 61 +++++++++++++++++++ Documentation/media/uapi/v4l/pixfmt-rgb.rst | 1 + drivers/media/v4l2-core/v4l2-ioctl.c | 4 ++ include/uapi/linux/videodev2.h | 7 +++ 4 files changed, 73 insertions(+) create mode 100644 Documentation/media/uapi/v4l/pixfmt-pfnc-bayerrg12p.rstDocumentation/media/uapi/v4l/pixfmt-pfnc-bayerrg12p.rst new file +61
-0@@ -0,0 +1,61 @@ +.. -*- coding: utf-8; mode: rst -*- + +.. _v4l2-pix-fmt-pfnc-bayergr12p: +.. _v4l2-pix-fmt-pfnc-bayerrg12p: +.. _v4l2-pix-fmt-pfnc-bayerbg12p: +.. _v4l2-pix-fmt-pfnc-bayergb12p: + +********************************************************************************************************************************************************** +V4L2_PIX_FMT_PFNC_BAYERBG12P ('BGCp'), V4L2_PIX_FMT_PFNC_BAYERGB12P ('GBCp'), V4L2_PIX_FMT_PFNC_BAYERGR12P ('GRCp'), V4L2_PIX_FMT_PFNC_BAYERRG12P ('RGCp') +********************************************************************************************************************************************************** + +12-bit Bayer formats + +Description +=========== + +These four pixel formats are used by industrial cameras, often in conjunction +with UsbVision (see https://www.visiononline.org/userAssets/aiaUploads/file/USB3_Vision_Specification_v1-0-1.pdf). + +The naming is in accordance to the Genicam Pixel Format Naming Convention +(see https://www.emva.org/wp-content/uploads/GenICam_PFNC_2_3.pdf). + +They are raw sRGB / Bayer formats with 12 bits +per sample with 3 bytes for every 2 pixels. + +The format is little endian. + +In other respects this format is similar to :ref:`v4l2-pix-fmt-ipu3-sbggr10`. +Below is an example of a small image in V4L2_PIX_FMT_PFNC_BAYERBG12P format. + +**Byte Order.** +Each cell is one byte. + +.. tabularcolumns:: |p{0.8cm}|p{4.0cm}|p{4.0cm}|p{4.0cm}|p{4.0cm}| + +.. flat-table:: + + * - start + 0: + - B\ :sub:`00low` + - G\ :sub:`01low`\ (bits 7--4) + B\ :sub:`00high`\ (bits 0--3) + - G\ :sub:`01high`\ + + * - start + 6: + - G\ :sub:`02low` + - R\ :sub:`03low`\ (bits 7--4) + G\ :sub:`02high`\ (bits 0--3) + - R\ :sub:`03high` + + * - start + 12: + - B\ :sub:`04low` + - G\ :sub:`05low`\ (bits 7--4) + B\ :sub:`04high`\ (bits 0--3) + - G\ :sub:`05high` + + * - start + 24: + - G\ :sub:`06low` + - R\ :sub:`07low`\ (bits 7--4) + G\ :sub:`06high`\ (bits 0--3) + - R\ :sub:`07high` +Documentation/media/uapi/v4l/pixfmt-rgb.rst +1
-0@@ -26,5 +26,6 @@ RGB Formats pixfmt-srggb10-ipu3 pixfmt-srggb12 pixfmt-srggb12p + pixfmt-pfnc-bayerrg12p pixfmt-srggb14p pixfmt-srggb16drivers/media/v4l2-core/v4l2-ioctl.c +4
-0@@ -1275,6 +1275,10 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)case V4L2_PIX_FMT_SGBRG12 : descr ="12-bit Bayer GBGB/RGRG" ;break ;case V4L2_PIX_FMT_SGRBG12 : descr ="12-bit Bayer GRGR/BGBG" ;break ;case V4L2_PIX_FMT_SRGGB12 : descr ="12-bit Bayer RGRG/GBGB" ;break ; +case V4L2_PIX_FMT_PFNC_BAYERBG12P : descr ="12-bit Bayer BGBG/GRGR PFNC Packed" ;break ; +case V4L2_PIX_FMT_PFNC_BAYERGB12P : descr ="12-bit Bayer GBGB/RGRG PFNC Packed" ;break ; +case V4L2_PIX_FMT_PFNC_BAYERGR12P : descr ="12-bit Bayer GRGR/BGBG PFNC Packed" ;break ; +case V4L2_PIX_FMT_PFNC_BAYERRG12P : descr ="12-bit Bayer RGRG/GBGB PFNC Packed" ;break ;case V4L2_PIX_FMT_SBGGR12P : descr ="12-bit Bayer BGBG/GRGR Packed" ;break ;case V4L2_PIX_FMT_SGBRG12P : descr ="12-bit Bayer GBGB/RGRG Packed" ;break ;case V4L2_PIX_FMT_SGRBG12P : descr ="12-bit Bayer GRGR/BGBG Packed" ;break ;include/uapi/linux/videodev2.h +7
-0@@ -646,6 +646,13 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_SGBRG12 v4l2_fourcc('G', 'B', '1', '2')/* 12 GBGB.. RGRG.. */ #define V4L2_PIX_FMT_SGRBG12 v4l2_fourcc('B', 'A', '1', '2')/* 12 GRGR.. BGBG.. */ #define V4L2_PIX_FMT_SRGGB12 v4l2_fourcc('R', 'G', '1', '2')/* 12 RGRG.. GBGB.. */ + +/* 12bit raw bayer simple packed, 6 bytes for every 4 pixels */ +#define V4L2_PIX_FMT_PFNC_BAYERBG12P v4l2_fourcc('B', 'G', 'C', 'p') +#define V4L2_PIX_FMT_PFNC_BAYERGB12P v4l2_fourcc('G', 'B', 'C', 'p') +#define V4L2_PIX_FMT_PFNC_BAYERGR12P v4l2_fourcc('G', 'R', 'C', 'p') +#define V4L2_PIX_FMT_PFNC_BAYERRG12P v4l2_fourcc('R', 'G', 'C', 'p') +/* 12bit raw bayer packed, 6 bytes for every 4 pixels */ #define V4L2_PIX_FMT_SBGGR12P v4l2_fourcc('p', 'B', 'C', 'C')#define V4L2_PIX_FMT_SGBRG12P v4l2_fourcc('p', 'G', 'C', 'C')
Signature · 3 lines
Kind regards, Sakari Ailus