All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH/RFC v2 0/3] fbdev: Add FOURCC-based format configuration API
@ 2011-08-19  9:37 ` Laurent Pinchart
  0 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-19  9:37 UTC (permalink / raw)
  To: linux-fbdev; +Cc: linux-media, magnus.damm

Hi everybody,

Here's the second version of the fbdev FOURCC-based format configuration API.

Compared to the previous version, I've removed the FB_VMODE_FOURCC bit (FOURCC
mode is now selected by a grayscale value > 1), reorganized the union in the
fb_var_screeninfo structure, and added a colorspace field used for YUV modes.

This patch set also contains an implementation of the FOURCC-based format API
for the sh_mobile_lcdc driver, based on top of the latest patches I've sent to
the list. You can find a consolidated version that includes this patch set at
http://git.linuxtv.org/pinchartl/fbdev.git/shortlog/refs/heads/fbdev-yuv.
YUV support when MERAM is enabled is currently broken, I'm working on fixing
that.

I've updated the fbdev-test tool to add FOURCC support. The code is available
in the fbdev-test yuv branch at
http://git.ideasonboard.org/?p=fbdev-test.git;a=shortlog;h=refs/heads/yuv.

Laurent Pinchart (3):
  fbdev: Add FOURCC-based format configuration API
  v4l: Add V4L2_PIX_FMT_NV24 and V4L2_PIX_FMT_NV42 formats
  fbdev: sh_mobile_lcdc: Support FOURCC-based format API

 Documentation/DocBook/media/v4l/pixfmt-nv24.xml |  128 +++++++++
 Documentation/DocBook/media/v4l/pixfmt.xml      |    1 +
 Documentation/fb/api.txt                        |  299 ++++++++++++++++++++
 arch/arm/mach-shmobile/board-ag5evm.c           |    2 +-
 arch/arm/mach-shmobile/board-ap4evb.c           |    4 +-
 arch/arm/mach-shmobile/board-mackerel.c         |    4 +-
 drivers/video/sh_mobile_lcdcfb.c                |  342 +++++++++++++++--------
 include/linux/fb.h                              |   27 ++-
 include/linux/videodev2.h                       |    2 +
 include/video/sh_mobile_lcdc.h                  |    4 +-
 10 files changed, 681 insertions(+), 132 deletions(-)
 create mode 100644 Documentation/DocBook/media/v4l/pixfmt-nv24.xml
 create mode 100644 Documentation/fb/api.txt

-- 
Regards,

Laurent Pinchart


^ permalink raw reply	[flat|nested] 52+ messages in thread

* [PATCH/RFC v2 0/3] fbdev: Add FOURCC-based format configuration API
@ 2011-08-19  9:37 ` Laurent Pinchart
  0 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-19  9:37 UTC (permalink / raw)
  To: linux-fbdev; +Cc: linux-media, magnus.damm

Hi everybody,

Here's the second version of the fbdev FOURCC-based format configuration API.

Compared to the previous version, I've removed the FB_VMODE_FOURCC bit (FOURCC
mode is now selected by a grayscale value > 1), reorganized the union in the
fb_var_screeninfo structure, and added a colorspace field used for YUV modes.

This patch set also contains an implementation of the FOURCC-based format API
for the sh_mobile_lcdc driver, based on top of the latest patches I've sent to
the list. You can find a consolidated version that includes this patch set at
http://git.linuxtv.org/pinchartl/fbdev.git/shortlog/refs/heads/fbdev-yuv.
YUV support when MERAM is enabled is currently broken, I'm working on fixing
that.

I've updated the fbdev-test tool to add FOURCC support. The code is available
in the fbdev-test yuv branch at
http://git.ideasonboard.org/?pûdev-test.git;a=shortlog;h=refs/heads/yuv.

Laurent Pinchart (3):
  fbdev: Add FOURCC-based format configuration API
  v4l: Add V4L2_PIX_FMT_NV24 and V4L2_PIX_FMT_NV42 formats
  fbdev: sh_mobile_lcdc: Support FOURCC-based format API

 Documentation/DocBook/media/v4l/pixfmt-nv24.xml |  128 +++++++++
 Documentation/DocBook/media/v4l/pixfmt.xml      |    1 +
 Documentation/fb/api.txt                        |  299 ++++++++++++++++++++
 arch/arm/mach-shmobile/board-ag5evm.c           |    2 +-
 arch/arm/mach-shmobile/board-ap4evb.c           |    4 +-
 arch/arm/mach-shmobile/board-mackerel.c         |    4 +-
 drivers/video/sh_mobile_lcdcfb.c                |  342 +++++++++++++++--------
 include/linux/fb.h                              |   27 ++-
 include/linux/videodev2.h                       |    2 +
 include/video/sh_mobile_lcdc.h                  |    4 +-
 10 files changed, 681 insertions(+), 132 deletions(-)
 create mode 100644 Documentation/DocBook/media/v4l/pixfmt-nv24.xml
 create mode 100644 Documentation/fb/api.txt

-- 
Regards,

Laurent Pinchart


^ permalink raw reply	[flat|nested] 52+ messages in thread

* [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
  2011-08-19  9:37 ` Laurent Pinchart
@ 2011-08-19  9:37   ` Laurent Pinchart
  -1 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-19  9:37 UTC (permalink / raw)
  To: linux-fbdev; +Cc: linux-media, magnus.damm

This API will be used to support YUV frame buffer formats in a standard
way.

Last but not least, create a much needed fbdev API documentation and
document the format setting APIs.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 Documentation/fb/api.txt |  299 ++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/fb.h       |   27 ++++-
 2 files changed, 320 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/fb/api.txt

diff --git a/Documentation/fb/api.txt b/Documentation/fb/api.txt
new file mode 100644
index 0000000..6808492
--- /dev/null
+++ b/Documentation/fb/api.txt
@@ -0,0 +1,299 @@
+			The Frame Buffer Device API
+			---------------------------
+
+Last revised: June 21, 2011
+
+
+0. Introduction
+---------------
+
+This document describes the frame buffer API used by applications to interact
+with frame buffer devices. In-kernel APIs between device drivers and the frame
+buffer core are not described.
+
+Due to a lack of documentation in the original frame buffer API, drivers
+behaviours differ in subtle (and not so subtle) ways. This document describes
+the recommended API implementation, but applications should be prepared to
+deal with different behaviours.
+
+
+1. Capabilities
+---------------
+
+Device and driver capabilities are reported in the fixed screen information
+capabilities field.
+
+struct fb_fix_screeninfo {
+	...
+	__u16 capabilities;		/* see FB_CAP_*			*/
+	...
+};
+
+Application should use those capabilities to find out what features they can
+expect from the device and driver.
+
+- FB_CAP_FOURCC
+
+The driver supports the four character code (FOURCC) based format setting API.
+When supported, formats are configured using a FOURCC instead of manually
+specifying color components layout.
+
+
+2. Types and visuals
+--------------------
+
+Pixels are stored in memory in hardware-dependent formats. Applications need
+to be aware of the pixel storage format in order to write image data to the
+frame buffer memory in the format expected by the hardware.
+
+Formats are described by frame buffer types and visuals. Some visuals require
+additional information, which are stored in the variable screen information
+bits_per_pixel, grayscale, fourcc, red, green, blue and transp fields.
+
+The following types and visuals are supported.
+
+- FB_TYPE_PACKED_PIXELS
+
+Color components (usually RGB or YUV) are packed together into macropixels
+that are stored in a single plane. The exact color components layout is
+described in a visual-dependent way.
+
+Frame buffer visuals that don't use multiple color components per pixel
+(such as monochrome and pseudo-color visuals) are reported as packed frame
+buffer types, even though they don't stricly speaking pack color components
+into macropixels.
+
+- FB_TYPE_PLANES
+
+Color components are stored in separate planes. Planes are located
+contiguously in memory.
+
+- FB_VISUAL_MONO01
+
+Pixels are black or white and stored on one bit. A bit set to 1 represents a
+black pixel and a bit set to 0 a white pixel. Pixels are packed together in
+bytes with 8 pixels per byte.
+
+FB_VISUAL_MONO01 is used with FB_TYPE_PACKED_PIXELS only.
+
+- FB_VISUAL_MONO10
+
+Pixels are black or white and stored on one bit. A bit set to 1 represents a
+white pixel and a bit set to 0 a black pixel. Pixels are packed together in
+bytes with 8 pixels per byte.
+
+FB_VISUAL_MONO01 is used with FB_TYPE_PACKED_PIXELS only.
+
+- FB_VISUAL_TRUECOLOR
+
+Pixels are broken into red, green and blue components, and each component
+indexes a read-only lookup table for the corresponding value. Lookup tables
+are device-dependent, and provide linear or non-linear ramps.
+
+Each component is stored in memory according to the variable screen
+information red, green, blue and transp fields.
+
+- FB_VISUAL_PSEUDOCOLOR and FB_VISUAL_STATIC_PSEUDOCOLOR
+
+Pixel values are encoded as indices into a colormap that stores red, green and
+blue components. The colormap is read-only for FB_VISUAL_STATIC_PSEUDOCOLOR
+and read-write for FB_VISUAL_PSEUDOCOLOR.
+
+Each pixel value is stored in the number of bits reported by the variable
+screen information bits_per_pixel field. Pixels are contiguous in memory.
+
+FB_VISUAL_PSEUDOCOLOR and FB_VISUAL_STATIC_PSEUDOCOLOR are used with
+FB_TYPE_PACKED_PIXELS only.
+
+- FB_VISUAL_DIRECTCOLOR
+
+Pixels are broken into red, green and blue components, and each component
+indexes a programmable lookup table for the corresponding value.
+
+Each component is stored in memory according to the variable screen
+information red, green, blue and transp fields.
+
+- FB_VISUAL_FOURCC
+
+Pixels are stored in memory as described by the format FOURCC identifier
+stored in the variable screen information fourcc field.
+
+
+3. Screen information
+---------------------
+
+Screen information are queried by applications using the FBIOGET_FSCREENINFO
+and FBIOGET_VSCREENINFO ioctls. Those ioctls take a pointer to a
+fb_fix_screeninfo and fb_var_screeninfo structure respectively.
+
+struct fb_fix_screeninfo stores device independent unchangeable information
+about the frame buffer device and the current format. Those information can't
+be directly modified by applications, but can be changed by the driver when an
+application modifies the format.
+
+struct fb_fix_screeninfo {
+	char id[16];			/* identification string eg "TT Builtin" */
+	unsigned long smem_start;	/* Start of frame buffer mem */
+					/* (physical address) */
+	__u32 smem_len;			/* Length of frame buffer mem */
+	__u32 type;			/* see FB_TYPE_*		*/
+	__u32 type_aux;			/* Interleave for interleaved Planes */
+	__u32 visual;			/* see FB_VISUAL_*		*/
+	__u16 xpanstep;			/* zero if no hardware panning  */
+	__u16 ypanstep;			/* zero if no hardware panning  */
+	__u16 ywrapstep;		/* zero if no hardware ywrap    */
+	__u32 line_length;		/* length of a line in bytes    */
+	unsigned long mmio_start;	/* Start of Memory Mapped I/O   */
+					/* (physical address) */
+	__u32 mmio_len;			/* Length of Memory Mapped I/O  */
+	__u32 accel;			/* Indicate to driver which	*/
+					/*  specific chip/card we have	*/
+	__u16 capabilities;		/* see FB_CAP_*			*/
+	__u16 reserved[2];		/* Reserved for future compatibility */
+};
+
+struct fb_var_screeninfo stores device independent changeable information
+about a frame buffer device, its current format and video mode, as well as
+other miscellaneous parameters.
+
+struct fb_var_screeninfo {
+	__u32 xres;			/* visible resolution		*/
+	__u32 yres;
+	__u32 xres_virtual;		/* virtual resolution		*/
+	__u32 yres_virtual;
+	__u32 xoffset;			/* offset from virtual to visible */
+	__u32 yoffset;			/* resolution			*/
+
+	__u32 bits_per_pixel;		/* guess what			*/
+	union {
+		struct {		/* Legacy format API		*/
+			__u32 grayscale; /* != 0 Graylevels instead of colors */
+			/* bitfields in fb mem if true color, else only */
+			/* length is significant			*/
+			struct fb_bitfield red;
+			struct fb_bitfield green;
+			struct fb_bitfield blue;
+			struct fb_bitfield transp;	/* transparency	*/
+		};
+		struct {		/* FOURCC-based format API	*/
+			__u32 fourcc;		/* FOURCC format	*/
+			__u32 colorspace;
+			__u32 reserved[11];
+		} format;
+	};
+
+	struct fb_bitfield red;		/* bitfield in fb mem if true color, */
+	struct fb_bitfield green;	/* else only length is significant */
+	struct fb_bitfield blue;
+	struct fb_bitfield transp;	/* transparency			*/
+
+	__u32 nonstd;			/* != 0 Non standard pixel format */
+
+	__u32 activate;			/* see FB_ACTIVATE_*		*/
+
+	__u32 height;			/* height of picture in mm    */
+	__u32 width;			/* width of picture in mm     */
+
+	__u32 accel_flags;		/* (OBSOLETE) see fb_info.flags */
+
+	/* Timing: All values in pixclocks, except pixclock (of course) */
+	__u32 pixclock;			/* pixel clock in ps (pico seconds) */
+	__u32 left_margin;		/* time from sync to picture	*/
+	__u32 right_margin;		/* time from picture to sync	*/
+	__u32 upper_margin;		/* time from sync to picture	*/
+	__u32 lower_margin;
+	__u32 hsync_len;		/* length of horizontal sync	*/
+	__u32 vsync_len;		/* length of vertical sync	*/
+	__u32 sync;			/* see FB_SYNC_*		*/
+	__u32 vmode;			/* see FB_VMODE_*		*/
+	__u32 rotate;			/* angle we rotate counter clockwise */
+	__u32 reserved[5];		/* Reserved for future compatibility */
+};
+
+To modify variable information, applications call the FBIOPUT_VSCREENINFO
+ioctl with a pointer to a fb_var_screeninfo structure. If the call is
+successful, the driver will update the fixed screen information accordingly.
+
+Instead of filling the complete fb_var_screeninfo structure manually,
+applications should call the FBIOGET_VSCREENINFO ioctl and modify only the
+fields they care about.
+
+
+4. Format configuration
+-----------------------
+
+Frame buffer devices offer two ways to configure the frame buffer format: the
+legacy API and the FOURCC-based API.
+
+
+The legacy API has been the only frame buffer format configuration API for a
+long time and is thus widely used by application. It is the recommended API
+for applications when using RGB and grayscale formats, as well as legacy
+non-standard formats.
+
+To select a format, applications set the fb_var_screeninfo bits_per_pixel field
+to the desired frame buffer depth. Values up to 8 will usually map to
+monochrome, grayscale or pseudocolor visuals, although this is not required.
+
+- For grayscale formats, applications set the grayscale field to a non-zero
+  value. The red, blue, green and transp fields must be set to 0 by
+  applications and ignored by drivers. Drivers must fill the red, blue and
+  green offsets to 0 and lengths to the bits_per_pixel value.
+
+- For pseudocolor formats, applications set the grayscale field to a zero
+  value. The red, blue, green and transp fields must be set to 0 by
+  applications and ignored by drivers. Drivers must fill the red, blue and
+  green offsets to 0 and lengths to the bits_per_pixel value.
+
+- For truecolor and directcolor formats, applications set the grayscale field
+  to a zero value, and the red, blue, green and transp fields to describe the
+  layout of color components in memory.
+
+struct fb_bitfield {
+	__u32 offset;			/* beginning of bitfield	*/
+	__u32 length;			/* length of bitfield		*/
+	__u32 msb_right;		/* != 0 : Most significant bit is */
+					/* right */
+};
+
+  Pixel values are bits_per_pixel wide and are split in non-overlapping red,
+  green, blue and alpha (transparency) components. Location and size of each
+  component in the pixel value are described by the fb_bitfield offset and
+  length fields. Offset are computed from the right.
+
+  Pixels are always stored in an integer number of bytes. If the number of
+  bits per pixel is not a multiple of 8, pixel values are padded to the next
+  multiple of 8 bits.
+
+Upon successful format configuration, drivers update the fb_fix_screeninfo
+type, visual and line_length fields depending on the selected format.
+
+
+The FOURCC-based API replaces format descriptions by four character codes
+(FOURCC). FOURCCs are abstract identifiers that uniquely define a format
+without explicitly describing it. This is the only API that supports YUV
+formats. Drivers are also encouraged to implement the FOURCC-based API for RGB
+and grayscale formats.
+
+Drivers that support the FOURCC-based API report this capability by setting
+the FB_CAP_FOURCC bit in the fb_fix_screeninfo capabilities field.
+
+FOURCC definitions are located in the linux/videodev2.h header. However, and
+despite starting with the V4L2_PIX_FMT_prefix, they are not restricted to V4L2
+and don't require usage of the V4L2 subsystem. FOURCC documentation is
+available in Documentation/DocBook/v4l/pixfmt.xml.
+
+To select a format, applications set the format.fourcc field to the desired
+FOURCC. For YUV formats, they should also select the appropriate colorspace by
+setting the format.colorspace field to one of the colorspaces listed in
+linux/videodev2.h and documented in Documentation/DocBook/v4l/colorspaces.xml.
+
+For forward compatibility reasons the format.reserved field must be set to 0 by
+applications and ignored by drivers. Values other than 0 may get a meaning in
+future extensions. Note that the grayscale, red, green, blue and transp field
+share memory with the format field. Application must thus not touch those
+fields when using the FOURCC-based API.
+
+Upon successful format configuration, drivers update the fb_fix_screeninfo
+type, visual and line_length fields depending on the selected format. The
+visual field is set to FB_VISUAL_FOURCC.
diff --git a/include/linux/fb.h b/include/linux/fb.h
index 1d6836c..c6baf28 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -69,6 +69,7 @@
 #define FB_VISUAL_PSEUDOCOLOR		3	/* Pseudo color (like atari) */
 #define FB_VISUAL_DIRECTCOLOR		4	/* Direct color */
 #define FB_VISUAL_STATIC_PSEUDOCOLOR	5	/* Pseudo color readonly */
+#define FB_VISUAL_FOURCC		6	/* Visual identified by a V4L2 FOURCC */
 
 #define FB_ACCEL_NONE		0	/* no hardware accelerator	*/
 #define FB_ACCEL_ATARIBLITT	1	/* Atari Blitter		*/
@@ -154,6 +155,8 @@
 
 #define FB_ACCEL_PUV3_UNIGFX	0xa0	/* PKUnity-v3 Unigfx		*/
 
+#define FB_CAP_FOURCC		1	/* Device supports FOURCC-based formats */
+
 struct fb_fix_screeninfo {
 	char id[16];			/* identification string eg "TT Builtin" */
 	unsigned long smem_start;	/* Start of frame buffer mem */
@@ -171,7 +174,8 @@ struct fb_fix_screeninfo {
 	__u32 mmio_len;			/* Length of Memory Mapped I/O  */
 	__u32 accel;			/* Indicate to driver which	*/
 					/*  specific chip/card we have	*/
-	__u16 reserved[3];		/* Reserved for future compatibility */
+	__u16 capabilities;		/* see FB_CAP_*			*/
+	__u16 reserved[2];		/* Reserved for future compatibility */
 };
 
 /* Interpretation of offset for color fields: All offsets are from the right,
@@ -246,12 +250,23 @@ struct fb_var_screeninfo {
 	__u32 yoffset;			/* resolution			*/
 
 	__u32 bits_per_pixel;		/* guess what			*/
-	__u32 grayscale;		/* != 0 Graylevels instead of colors */
 
-	struct fb_bitfield red;		/* bitfield in fb mem if true color, */
-	struct fb_bitfield green;	/* else only length is significant */
-	struct fb_bitfield blue;
-	struct fb_bitfield transp;	/* transparency			*/	
+	union {
+		struct {		/* Legacy format API		*/
+			__u32 grayscale; /* != 0 Graylevels instead of colors */
+			/* bitfields in fb mem if true color, else only */
+			/* length is significant			*/
+			struct fb_bitfield red;
+			struct fb_bitfield green;
+			struct fb_bitfield blue;
+			struct fb_bitfield transp;	/* transparency	*/
+		};
+		struct {		/* FOURCC-based format API	*/
+			__u32 fourcc;		/* FOURCC format	*/
+			__u32 colorspace;
+			__u32 reserved[11];
+		} format;
+	};
 
 	__u32 nonstd;			/* != 0 Non standard pixel format */
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
@ 2011-08-19  9:37   ` Laurent Pinchart
  0 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-19  9:37 UTC (permalink / raw)
  To: linux-fbdev; +Cc: linux-media, magnus.damm

This API will be used to support YUV frame buffer formats in a standard
way.

Last but not least, create a much needed fbdev API documentation and
document the format setting APIs.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 Documentation/fb/api.txt |  299 ++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/fb.h       |   27 ++++-
 2 files changed, 320 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/fb/api.txt

diff --git a/Documentation/fb/api.txt b/Documentation/fb/api.txt
new file mode 100644
index 0000000..6808492
--- /dev/null
+++ b/Documentation/fb/api.txt
@@ -0,0 +1,299 @@
+			The Frame Buffer Device API
+			---------------------------
+
+Last revised: June 21, 2011
+
+
+0. Introduction
+---------------
+
+This document describes the frame buffer API used by applications to interact
+with frame buffer devices. In-kernel APIs between device drivers and the frame
+buffer core are not described.
+
+Due to a lack of documentation in the original frame buffer API, drivers
+behaviours differ in subtle (and not so subtle) ways. This document describes
+the recommended API implementation, but applications should be prepared to
+deal with different behaviours.
+
+
+1. Capabilities
+---------------
+
+Device and driver capabilities are reported in the fixed screen information
+capabilities field.
+
+struct fb_fix_screeninfo {
+	...
+	__u16 capabilities;		/* see FB_CAP_*			*/
+	...
+};
+
+Application should use those capabilities to find out what features they can
+expect from the device and driver.
+
+- FB_CAP_FOURCC
+
+The driver supports the four character code (FOURCC) based format setting API.
+When supported, formats are configured using a FOURCC instead of manually
+specifying color components layout.
+
+
+2. Types and visuals
+--------------------
+
+Pixels are stored in memory in hardware-dependent formats. Applications need
+to be aware of the pixel storage format in order to write image data to the
+frame buffer memory in the format expected by the hardware.
+
+Formats are described by frame buffer types and visuals. Some visuals require
+additional information, which are stored in the variable screen information
+bits_per_pixel, grayscale, fourcc, red, green, blue and transp fields.
+
+The following types and visuals are supported.
+
+- FB_TYPE_PACKED_PIXELS
+
+Color components (usually RGB or YUV) are packed together into macropixels
+that are stored in a single plane. The exact color components layout is
+described in a visual-dependent way.
+
+Frame buffer visuals that don't use multiple color components per pixel
+(such as monochrome and pseudo-color visuals) are reported as packed frame
+buffer types, even though they don't stricly speaking pack color components
+into macropixels.
+
+- FB_TYPE_PLANES
+
+Color components are stored in separate planes. Planes are located
+contiguously in memory.
+
+- FB_VISUAL_MONO01
+
+Pixels are black or white and stored on one bit. A bit set to 1 represents a
+black pixel and a bit set to 0 a white pixel. Pixels are packed together in
+bytes with 8 pixels per byte.
+
+FB_VISUAL_MONO01 is used with FB_TYPE_PACKED_PIXELS only.
+
+- FB_VISUAL_MONO10
+
+Pixels are black or white and stored on one bit. A bit set to 1 represents a
+white pixel and a bit set to 0 a black pixel. Pixels are packed together in
+bytes with 8 pixels per byte.
+
+FB_VISUAL_MONO01 is used with FB_TYPE_PACKED_PIXELS only.
+
+- FB_VISUAL_TRUECOLOR
+
+Pixels are broken into red, green and blue components, and each component
+indexes a read-only lookup table for the corresponding value. Lookup tables
+are device-dependent, and provide linear or non-linear ramps.
+
+Each component is stored in memory according to the variable screen
+information red, green, blue and transp fields.
+
+- FB_VISUAL_PSEUDOCOLOR and FB_VISUAL_STATIC_PSEUDOCOLOR
+
+Pixel values are encoded as indices into a colormap that stores red, green and
+blue components. The colormap is read-only for FB_VISUAL_STATIC_PSEUDOCOLOR
+and read-write for FB_VISUAL_PSEUDOCOLOR.
+
+Each pixel value is stored in the number of bits reported by the variable
+screen information bits_per_pixel field. Pixels are contiguous in memory.
+
+FB_VISUAL_PSEUDOCOLOR and FB_VISUAL_STATIC_PSEUDOCOLOR are used with
+FB_TYPE_PACKED_PIXELS only.
+
+- FB_VISUAL_DIRECTCOLOR
+
+Pixels are broken into red, green and blue components, and each component
+indexes a programmable lookup table for the corresponding value.
+
+Each component is stored in memory according to the variable screen
+information red, green, blue and transp fields.
+
+- FB_VISUAL_FOURCC
+
+Pixels are stored in memory as described by the format FOURCC identifier
+stored in the variable screen information fourcc field.
+
+
+3. Screen information
+---------------------
+
+Screen information are queried by applications using the FBIOGET_FSCREENINFO
+and FBIOGET_VSCREENINFO ioctls. Those ioctls take a pointer to a
+fb_fix_screeninfo and fb_var_screeninfo structure respectively.
+
+struct fb_fix_screeninfo stores device independent unchangeable information
+about the frame buffer device and the current format. Those information can't
+be directly modified by applications, but can be changed by the driver when an
+application modifies the format.
+
+struct fb_fix_screeninfo {
+	char id[16];			/* identification string eg "TT Builtin" */
+	unsigned long smem_start;	/* Start of frame buffer mem */
+					/* (physical address) */
+	__u32 smem_len;			/* Length of frame buffer mem */
+	__u32 type;			/* see FB_TYPE_*		*/
+	__u32 type_aux;			/* Interleave for interleaved Planes */
+	__u32 visual;			/* see FB_VISUAL_*		*/
+	__u16 xpanstep;			/* zero if no hardware panning  */
+	__u16 ypanstep;			/* zero if no hardware panning  */
+	__u16 ywrapstep;		/* zero if no hardware ywrap    */
+	__u32 line_length;		/* length of a line in bytes    */
+	unsigned long mmio_start;	/* Start of Memory Mapped I/O   */
+					/* (physical address) */
+	__u32 mmio_len;			/* Length of Memory Mapped I/O  */
+	__u32 accel;			/* Indicate to driver which	*/
+					/*  specific chip/card we have	*/
+	__u16 capabilities;		/* see FB_CAP_*			*/
+	__u16 reserved[2];		/* Reserved for future compatibility */
+};
+
+struct fb_var_screeninfo stores device independent changeable information
+about a frame buffer device, its current format and video mode, as well as
+other miscellaneous parameters.
+
+struct fb_var_screeninfo {
+	__u32 xres;			/* visible resolution		*/
+	__u32 yres;
+	__u32 xres_virtual;		/* virtual resolution		*/
+	__u32 yres_virtual;
+	__u32 xoffset;			/* offset from virtual to visible */
+	__u32 yoffset;			/* resolution			*/
+
+	__u32 bits_per_pixel;		/* guess what			*/
+	union {
+		struct {		/* Legacy format API		*/
+			__u32 grayscale; /* != 0 Graylevels instead of colors */
+			/* bitfields in fb mem if true color, else only */
+			/* length is significant			*/
+			struct fb_bitfield red;
+			struct fb_bitfield green;
+			struct fb_bitfield blue;
+			struct fb_bitfield transp;	/* transparency	*/
+		};
+		struct {		/* FOURCC-based format API	*/
+			__u32 fourcc;		/* FOURCC format	*/
+			__u32 colorspace;
+			__u32 reserved[11];
+		} format;
+	};
+
+	struct fb_bitfield red;		/* bitfield in fb mem if true color, */
+	struct fb_bitfield green;	/* else only length is significant */
+	struct fb_bitfield blue;
+	struct fb_bitfield transp;	/* transparency			*/
+
+	__u32 nonstd;			/* != 0 Non standard pixel format */
+
+	__u32 activate;			/* see FB_ACTIVATE_*		*/
+
+	__u32 height;			/* height of picture in mm    */
+	__u32 width;			/* width of picture in mm     */
+
+	__u32 accel_flags;		/* (OBSOLETE) see fb_info.flags */
+
+	/* Timing: All values in pixclocks, except pixclock (of course) */
+	__u32 pixclock;			/* pixel clock in ps (pico seconds) */
+	__u32 left_margin;		/* time from sync to picture	*/
+	__u32 right_margin;		/* time from picture to sync	*/
+	__u32 upper_margin;		/* time from sync to picture	*/
+	__u32 lower_margin;
+	__u32 hsync_len;		/* length of horizontal sync	*/
+	__u32 vsync_len;		/* length of vertical sync	*/
+	__u32 sync;			/* see FB_SYNC_*		*/
+	__u32 vmode;			/* see FB_VMODE_*		*/
+	__u32 rotate;			/* angle we rotate counter clockwise */
+	__u32 reserved[5];		/* Reserved for future compatibility */
+};
+
+To modify variable information, applications call the FBIOPUT_VSCREENINFO
+ioctl with a pointer to a fb_var_screeninfo structure. If the call is
+successful, the driver will update the fixed screen information accordingly.
+
+Instead of filling the complete fb_var_screeninfo structure manually,
+applications should call the FBIOGET_VSCREENINFO ioctl and modify only the
+fields they care about.
+
+
+4. Format configuration
+-----------------------
+
+Frame buffer devices offer two ways to configure the frame buffer format: the
+legacy API and the FOURCC-based API.
+
+
+The legacy API has been the only frame buffer format configuration API for a
+long time and is thus widely used by application. It is the recommended API
+for applications when using RGB and grayscale formats, as well as legacy
+non-standard formats.
+
+To select a format, applications set the fb_var_screeninfo bits_per_pixel field
+to the desired frame buffer depth. Values up to 8 will usually map to
+monochrome, grayscale or pseudocolor visuals, although this is not required.
+
+- For grayscale formats, applications set the grayscale field to a non-zero
+  value. The red, blue, green and transp fields must be set to 0 by
+  applications and ignored by drivers. Drivers must fill the red, blue and
+  green offsets to 0 and lengths to the bits_per_pixel value.
+
+- For pseudocolor formats, applications set the grayscale field to a zero
+  value. The red, blue, green and transp fields must be set to 0 by
+  applications and ignored by drivers. Drivers must fill the red, blue and
+  green offsets to 0 and lengths to the bits_per_pixel value.
+
+- For truecolor and directcolor formats, applications set the grayscale field
+  to a zero value, and the red, blue, green and transp fields to describe the
+  layout of color components in memory.
+
+struct fb_bitfield {
+	__u32 offset;			/* beginning of bitfield	*/
+	__u32 length;			/* length of bitfield		*/
+	__u32 msb_right;		/* != 0 : Most significant bit is */
+					/* right */
+};
+
+  Pixel values are bits_per_pixel wide and are split in non-overlapping red,
+  green, blue and alpha (transparency) components. Location and size of each
+  component in the pixel value are described by the fb_bitfield offset and
+  length fields. Offset are computed from the right.
+
+  Pixels are always stored in an integer number of bytes. If the number of
+  bits per pixel is not a multiple of 8, pixel values are padded to the next
+  multiple of 8 bits.
+
+Upon successful format configuration, drivers update the fb_fix_screeninfo
+type, visual and line_length fields depending on the selected format.
+
+
+The FOURCC-based API replaces format descriptions by four character codes
+(FOURCC). FOURCCs are abstract identifiers that uniquely define a format
+without explicitly describing it. This is the only API that supports YUV
+formats. Drivers are also encouraged to implement the FOURCC-based API for RGB
+and grayscale formats.
+
+Drivers that support the FOURCC-based API report this capability by setting
+the FB_CAP_FOURCC bit in the fb_fix_screeninfo capabilities field.
+
+FOURCC definitions are located in the linux/videodev2.h header. However, and
+despite starting with the V4L2_PIX_FMT_prefix, they are not restricted to V4L2
+and don't require usage of the V4L2 subsystem. FOURCC documentation is
+available in Documentation/DocBook/v4l/pixfmt.xml.
+
+To select a format, applications set the format.fourcc field to the desired
+FOURCC. For YUV formats, they should also select the appropriate colorspace by
+setting the format.colorspace field to one of the colorspaces listed in
+linux/videodev2.h and documented in Documentation/DocBook/v4l/colorspaces.xml.
+
+For forward compatibility reasons the format.reserved field must be set to 0 by
+applications and ignored by drivers. Values other than 0 may get a meaning in
+future extensions. Note that the grayscale, red, green, blue and transp field
+share memory with the format field. Application must thus not touch those
+fields when using the FOURCC-based API.
+
+Upon successful format configuration, drivers update the fb_fix_screeninfo
+type, visual and line_length fields depending on the selected format. The
+visual field is set to FB_VISUAL_FOURCC.
diff --git a/include/linux/fb.h b/include/linux/fb.h
index 1d6836c..c6baf28 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -69,6 +69,7 @@
 #define FB_VISUAL_PSEUDOCOLOR		3	/* Pseudo color (like atari) */
 #define FB_VISUAL_DIRECTCOLOR		4	/* Direct color */
 #define FB_VISUAL_STATIC_PSEUDOCOLOR	5	/* Pseudo color readonly */
+#define FB_VISUAL_FOURCC		6	/* Visual identified by a V4L2 FOURCC */
 
 #define FB_ACCEL_NONE		0	/* no hardware accelerator	*/
 #define FB_ACCEL_ATARIBLITT	1	/* Atari Blitter		*/
@@ -154,6 +155,8 @@
 
 #define FB_ACCEL_PUV3_UNIGFX	0xa0	/* PKUnity-v3 Unigfx		*/
 
+#define FB_CAP_FOURCC		1	/* Device supports FOURCC-based formats */
+
 struct fb_fix_screeninfo {
 	char id[16];			/* identification string eg "TT Builtin" */
 	unsigned long smem_start;	/* Start of frame buffer mem */
@@ -171,7 +174,8 @@ struct fb_fix_screeninfo {
 	__u32 mmio_len;			/* Length of Memory Mapped I/O  */
 	__u32 accel;			/* Indicate to driver which	*/
 					/*  specific chip/card we have	*/
-	__u16 reserved[3];		/* Reserved for future compatibility */
+	__u16 capabilities;		/* see FB_CAP_*			*/
+	__u16 reserved[2];		/* Reserved for future compatibility */
 };
 
 /* Interpretation of offset for color fields: All offsets are from the right,
@@ -246,12 +250,23 @@ struct fb_var_screeninfo {
 	__u32 yoffset;			/* resolution			*/
 
 	__u32 bits_per_pixel;		/* guess what			*/
-	__u32 grayscale;		/* != 0 Graylevels instead of colors */
 
-	struct fb_bitfield red;		/* bitfield in fb mem if true color, */
-	struct fb_bitfield green;	/* else only length is significant */
-	struct fb_bitfield blue;
-	struct fb_bitfield transp;	/* transparency			*/	
+	union {
+		struct {		/* Legacy format API		*/
+			__u32 grayscale; /* != 0 Graylevels instead of colors */
+			/* bitfields in fb mem if true color, else only */
+			/* length is significant			*/
+			struct fb_bitfield red;
+			struct fb_bitfield green;
+			struct fb_bitfield blue;
+			struct fb_bitfield transp;	/* transparency	*/
+		};
+		struct {		/* FOURCC-based format API	*/
+			__u32 fourcc;		/* FOURCC format	*/
+			__u32 colorspace;
+			__u32 reserved[11];
+		} format;
+	};
 
 	__u32 nonstd;			/* != 0 Non standard pixel format */
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH/RFC v2 2/3] v4l: Add V4L2_PIX_FMT_NV24 and V4L2_PIX_FMT_NV42 formats
  2011-08-19  9:37 ` Laurent Pinchart
@ 2011-08-19  9:37   ` Laurent Pinchart
  -1 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-19  9:37 UTC (permalink / raw)
  To: linux-fbdev; +Cc: linux-media, magnus.damm

NV24 and NV42 are planar YCbCr 4:4:4 and YCrCb 4:4:4 formats with a
luma plane followed by an interleaved chroma plane.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 Documentation/DocBook/media/v4l/pixfmt-nv24.xml |  128 +++++++++++++++++++++++
 Documentation/DocBook/media/v4l/pixfmt.xml      |    1 +
 include/linux/videodev2.h                       |    2 +
 3 files changed, 131 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/DocBook/media/v4l/pixfmt-nv24.xml

diff --git a/Documentation/DocBook/media/v4l/pixfmt-nv24.xml b/Documentation/DocBook/media/v4l/pixfmt-nv24.xml
new file mode 100644
index 0000000..e77301d
--- /dev/null
+++ b/Documentation/DocBook/media/v4l/pixfmt-nv24.xml
@@ -0,0 +1,128 @@
+    <refentry>
+      <refmeta>
+	<refentrytitle>V4L2_PIX_FMT_NV24 ('NV24'), V4L2_PIX_FMT_NV42 ('NV42')</refentrytitle>
+	&manvol;
+      </refmeta>
+      <refnamediv>
+	<refname id="V4L2-PIX-FMT-NV24"><constant>V4L2_PIX_FMT_NV24</constant></refname>
+	<refname id="V4L2-PIX-FMT-NV42"><constant>V4L2_PIX_FMT_NV42</constant></refname>
+	<refpurpose>Formats with full horizontal and vertical
+chroma resolutions, also known as YUV 4:4:4. One luminance and one
+chrominance plane with alternating chroma samples as opposed to
+<constant>V4L2_PIX_FMT_YVU420</constant></refpurpose>
+      </refnamediv>
+      <refsect1>
+	<title>Description</title>
+
+	<para>These are two-plane versions of the YUV 4:4:4 format.
+The three components are separated into two sub-images or planes. The
+Y plane is first. The Y plane has one byte per pixel. For
+<constant>V4L2_PIX_FMT_NV24</constant>, a combined CbCr plane
+immediately follows the Y plane in memory.  The CbCr plane is the same
+width and height, in pixels, as the Y plane (and of the image).
+Each line contains one CbCr pair per pixel.
+<constant>V4L2_PIX_FMT_NV42</constant> is the same except the Cb and
+Cr bytes are swapped, the CrCb plane starts with a Cr byte.</para>
+
+	<para>If the Y plane has pad bytes after each row, then the
+CbCr plane has twice as many pad bytes after its rows.</para>
+
+	<example>
+	  <title><constant>V4L2_PIX_FMT_NV24</constant> 4 &times; 4
+pixel image</title>
+
+	  <formalpara>
+	    <title>Byte Order.</title>
+	    <para>Each cell is one byte.
+		<informaltable frame="none">
+		<tgroup cols="9" align="center">
+		  <colspec align="left" colwidth="2*" />
+		  <tbody valign="top">
+		    <row>
+		      <entry>start&nbsp;+&nbsp;0:</entry>
+		      <entry>Y'<subscript>00</subscript></entry>
+		      <entry>Y'<subscript>01</subscript></entry>
+		      <entry>Y'<subscript>02</subscript></entry>
+		      <entry>Y'<subscript>03</subscript></entry>
+		    </row>
+		    <row>
+		      <entry>start&nbsp;+&nbsp;4:</entry>
+		      <entry>Y'<subscript>10</subscript></entry>
+		      <entry>Y'<subscript>11</subscript></entry>
+		      <entry>Y'<subscript>12</subscript></entry>
+		      <entry>Y'<subscript>13</subscript></entry>
+		    </row>
+		    <row>
+		      <entry>start&nbsp;+&nbsp;8:</entry>
+		      <entry>Y'<subscript>20</subscript></entry>
+		      <entry>Y'<subscript>21</subscript></entry>
+		      <entry>Y'<subscript>22</subscript></entry>
+		      <entry>Y'<subscript>23</subscript></entry>
+		    </row>
+		    <row>
+		      <entry>start&nbsp;+&nbsp;12:</entry>
+		      <entry>Y'<subscript>30</subscript></entry>
+		      <entry>Y'<subscript>31</subscript></entry>
+		      <entry>Y'<subscript>32</subscript></entry>
+		      <entry>Y'<subscript>33</subscript></entry>
+		    </row>
+		    <row>
+		      <entry>start&nbsp;+&nbsp;16:</entry>
+		      <entry>Cb<subscript>00</subscript></entry>
+		      <entry>Cr<subscript>00</subscript></entry>
+		      <entry>Cb<subscript>01</subscript></entry>
+		      <entry>Cr<subscript>01</subscript></entry>
+		      <entry>Cb<subscript>02</subscript></entry>
+		      <entry>Cr<subscript>02</subscript></entry>
+		      <entry>Cb<subscript>03</subscript></entry>
+		      <entry>Cr<subscript>03</subscript></entry>
+		    </row>
+		    <row>
+		      <entry>start&nbsp;+&nbsp;24:</entry>
+		      <entry>Cb<subscript>10</subscript></entry>
+		      <entry>Cr<subscript>10</subscript></entry>
+		      <entry>Cb<subscript>11</subscript></entry>
+		      <entry>Cr<subscript>11</subscript></entry>
+		      <entry>Cb<subscript>12</subscript></entry>
+		      <entry>Cr<subscript>12</subscript></entry>
+		      <entry>Cb<subscript>13</subscript></entry>
+		      <entry>Cr<subscript>13</subscript></entry>
+		    </row>
+		    <row>
+		      <entry>start&nbsp;+&nbsp;32:</entry>
+		      <entry>Cb<subscript>20</subscript></entry>
+		      <entry>Cr<subscript>20</subscript></entry>
+		      <entry>Cb<subscript>21</subscript></entry>
+		      <entry>Cr<subscript>21</subscript></entry>
+		      <entry>Cb<subscript>22</subscript></entry>
+		      <entry>Cr<subscript>22</subscript></entry>
+		      <entry>Cb<subscript>23</subscript></entry>
+		      <entry>Cr<subscript>23</subscript></entry>
+		    </row>
+		    <row>
+		      <entry>start&nbsp;+&nbsp;40:</entry>
+		      <entry>Cb<subscript>30</subscript></entry>
+		      <entry>Cr<subscript>30</subscript></entry>
+		      <entry>Cb<subscript>31</subscript></entry>
+		      <entry>Cr<subscript>31</subscript></entry>
+		      <entry>Cb<subscript>32</subscript></entry>
+		      <entry>Cr<subscript>32</subscript></entry>
+		      <entry>Cb<subscript>33</subscript></entry>
+		      <entry>Cr<subscript>33</subscript></entry>
+		    </row>
+		  </tbody>
+		</tgroup>
+		</informaltable>
+	      </para>
+	  </formalpara>
+	</example>
+      </refsect1>
+    </refentry>
+
+  <!--
+Local Variables:
+mode: sgml
+sgml-parent-document: "pixfmt.sgml"
+indent-tabs-mode: nil
+End:
+  -->
diff --git a/Documentation/DocBook/media/v4l/pixfmt.xml b/Documentation/DocBook/media/v4l/pixfmt.xml
index 2ff6b77..aef4615 100644
--- a/Documentation/DocBook/media/v4l/pixfmt.xml
+++ b/Documentation/DocBook/media/v4l/pixfmt.xml
@@ -714,6 +714,7 @@ information.</para>
     &sub-nv12m;
     &sub-nv12mt;
     &sub-nv16;
+    &sub-nv24;
     &sub-m420;
   </section>
 
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index fca24cc..8225163 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -343,6 +343,8 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_NV21    v4l2_fourcc('N', 'V', '2', '1') /* 12  Y/CrCb 4:2:0  */
 #define V4L2_PIX_FMT_NV16    v4l2_fourcc('N', 'V', '1', '6') /* 16  Y/CbCr 4:2:2  */
 #define V4L2_PIX_FMT_NV61    v4l2_fourcc('N', 'V', '6', '1') /* 16  Y/CrCb 4:2:2  */
+#define V4L2_PIX_FMT_NV24    v4l2_fourcc('N', 'V', '2', '4') /* 24  Y/CbCr 4:4:4  */
+#define V4L2_PIX_FMT_NV42    v4l2_fourcc('N', 'V', '4', '2') /* 24  Y/CrCb 4:4:4  */
 
 /* two non contiguous planes - one Y, one Cr + Cb interleaved  */
 #define V4L2_PIX_FMT_NV12M   v4l2_fourcc('N', 'M', '1', '2') /* 12  Y/CbCr 4:2:0  */
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH/RFC v2 2/3] v4l: Add V4L2_PIX_FMT_NV24 and V4L2_PIX_FMT_NV42 formats
@ 2011-08-19  9:37   ` Laurent Pinchart
  0 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-19  9:37 UTC (permalink / raw)
  To: linux-fbdev; +Cc: linux-media, magnus.damm

NV24 and NV42 are planar YCbCr 4:4:4 and YCrCb 4:4:4 formats with a
luma plane followed by an interleaved chroma plane.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 Documentation/DocBook/media/v4l/pixfmt-nv24.xml |  128 +++++++++++++++++++++++
 Documentation/DocBook/media/v4l/pixfmt.xml      |    1 +
 include/linux/videodev2.h                       |    2 +
 3 files changed, 131 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/DocBook/media/v4l/pixfmt-nv24.xml

diff --git a/Documentation/DocBook/media/v4l/pixfmt-nv24.xml b/Documentation/DocBook/media/v4l/pixfmt-nv24.xml
new file mode 100644
index 0000000..e77301d
--- /dev/null
+++ b/Documentation/DocBook/media/v4l/pixfmt-nv24.xml
@@ -0,0 +1,128 @@
+    <refentry>
+      <refmeta>
+	<refentrytitle>V4L2_PIX_FMT_NV24 ('NV24'), V4L2_PIX_FMT_NV42 ('NV42')</refentrytitle>
+	&manvol;
+      </refmeta>
+      <refnamediv>
+	<refname id="V4L2-PIX-FMT-NV24"><constant>V4L2_PIX_FMT_NV24</constant></refname>
+	<refname id="V4L2-PIX-FMT-NV42"><constant>V4L2_PIX_FMT_NV42</constant></refname>
+	<refpurpose>Formats with full horizontal and vertical
+chroma resolutions, also known as YUV 4:4:4. One luminance and one
+chrominance plane with alternating chroma samples as opposed to
+<constant>V4L2_PIX_FMT_YVU420</constant></refpurpose>
+      </refnamediv>
+      <refsect1>
+	<title>Description</title>
+
+	<para>These are two-plane versions of the YUV 4:4:4 format.
+The three components are separated into two sub-images or planes. The
+Y plane is first. The Y plane has one byte per pixel. For
+<constant>V4L2_PIX_FMT_NV24</constant>, a combined CbCr plane
+immediately follows the Y plane in memory.  The CbCr plane is the same
+width and height, in pixels, as the Y plane (and of the image).
+Each line contains one CbCr pair per pixel.
+<constant>V4L2_PIX_FMT_NV42</constant> is the same except the Cb and
+Cr bytes are swapped, the CrCb plane starts with a Cr byte.</para>
+
+	<para>If the Y plane has pad bytes after each row, then the
+CbCr plane has twice as many pad bytes after its rows.</para>
+
+	<example>
+	  <title><constant>V4L2_PIX_FMT_NV24</constant> 4 &times; 4
+pixel image</title>
+
+	  <formalpara>
+	    <title>Byte Order.</title>
+	    <para>Each cell is one byte.
+		<informaltable frame="none">
+		<tgroup cols="9" align="center">
+		  <colspec align="left" colwidth="2*" />
+		  <tbody valign="top">
+		    <row>
+		      <entry>start&nbsp;+&nbsp;0:</entry>
+		      <entry>Y'<subscript>00</subscript></entry>
+		      <entry>Y'<subscript>01</subscript></entry>
+		      <entry>Y'<subscript>02</subscript></entry>
+		      <entry>Y'<subscript>03</subscript></entry>
+		    </row>
+		    <row>
+		      <entry>start&nbsp;+&nbsp;4:</entry>
+		      <entry>Y'<subscript>10</subscript></entry>
+		      <entry>Y'<subscript>11</subscript></entry>
+		      <entry>Y'<subscript>12</subscript></entry>
+		      <entry>Y'<subscript>13</subscript></entry>
+		    </row>
+		    <row>
+		      <entry>start&nbsp;+&nbsp;8:</entry>
+		      <entry>Y'<subscript>20</subscript></entry>
+		      <entry>Y'<subscript>21</subscript></entry>
+		      <entry>Y'<subscript>22</subscript></entry>
+		      <entry>Y'<subscript>23</subscript></entry>
+		    </row>
+		    <row>
+		      <entry>start&nbsp;+&nbsp;12:</entry>
+		      <entry>Y'<subscript>30</subscript></entry>
+		      <entry>Y'<subscript>31</subscript></entry>
+		      <entry>Y'<subscript>32</subscript></entry>
+		      <entry>Y'<subscript>33</subscript></entry>
+		    </row>
+		    <row>
+		      <entry>start&nbsp;+&nbsp;16:</entry>
+		      <entry>Cb<subscript>00</subscript></entry>
+		      <entry>Cr<subscript>00</subscript></entry>
+		      <entry>Cb<subscript>01</subscript></entry>
+		      <entry>Cr<subscript>01</subscript></entry>
+		      <entry>Cb<subscript>02</subscript></entry>
+		      <entry>Cr<subscript>02</subscript></entry>
+		      <entry>Cb<subscript>03</subscript></entry>
+		      <entry>Cr<subscript>03</subscript></entry>
+		    </row>
+		    <row>
+		      <entry>start&nbsp;+&nbsp;24:</entry>
+		      <entry>Cb<subscript>10</subscript></entry>
+		      <entry>Cr<subscript>10</subscript></entry>
+		      <entry>Cb<subscript>11</subscript></entry>
+		      <entry>Cr<subscript>11</subscript></entry>
+		      <entry>Cb<subscript>12</subscript></entry>
+		      <entry>Cr<subscript>12</subscript></entry>
+		      <entry>Cb<subscript>13</subscript></entry>
+		      <entry>Cr<subscript>13</subscript></entry>
+		    </row>
+		    <row>
+		      <entry>start&nbsp;+&nbsp;32:</entry>
+		      <entry>Cb<subscript>20</subscript></entry>
+		      <entry>Cr<subscript>20</subscript></entry>
+		      <entry>Cb<subscript>21</subscript></entry>
+		      <entry>Cr<subscript>21</subscript></entry>
+		      <entry>Cb<subscript>22</subscript></entry>
+		      <entry>Cr<subscript>22</subscript></entry>
+		      <entry>Cb<subscript>23</subscript></entry>
+		      <entry>Cr<subscript>23</subscript></entry>
+		    </row>
+		    <row>
+		      <entry>start&nbsp;+&nbsp;40:</entry>
+		      <entry>Cb<subscript>30</subscript></entry>
+		      <entry>Cr<subscript>30</subscript></entry>
+		      <entry>Cb<subscript>31</subscript></entry>
+		      <entry>Cr<subscript>31</subscript></entry>
+		      <entry>Cb<subscript>32</subscript></entry>
+		      <entry>Cr<subscript>32</subscript></entry>
+		      <entry>Cb<subscript>33</subscript></entry>
+		      <entry>Cr<subscript>33</subscript></entry>
+		    </row>
+		  </tbody>
+		</tgroup>
+		</informaltable>
+	      </para>
+	  </formalpara>
+	</example>
+      </refsect1>
+    </refentry>
+
+  <!--
+Local Variables:
+mode: sgml
+sgml-parent-document: "pixfmt.sgml"
+indent-tabs-mode: nil
+End:
+  -->
diff --git a/Documentation/DocBook/media/v4l/pixfmt.xml b/Documentation/DocBook/media/v4l/pixfmt.xml
index 2ff6b77..aef4615 100644
--- a/Documentation/DocBook/media/v4l/pixfmt.xml
+++ b/Documentation/DocBook/media/v4l/pixfmt.xml
@@ -714,6 +714,7 @@ information.</para>
     &sub-nv12m;
     &sub-nv12mt;
     &sub-nv16;
+    &sub-nv24;
     &sub-m420;
   </section>
 
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index fca24cc..8225163 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -343,6 +343,8 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_NV21    v4l2_fourcc('N', 'V', '2', '1') /* 12  Y/CrCb 4:2:0  */
 #define V4L2_PIX_FMT_NV16    v4l2_fourcc('N', 'V', '1', '6') /* 16  Y/CbCr 4:2:2  */
 #define V4L2_PIX_FMT_NV61    v4l2_fourcc('N', 'V', '6', '1') /* 16  Y/CrCb 4:2:2  */
+#define V4L2_PIX_FMT_NV24    v4l2_fourcc('N', 'V', '2', '4') /* 24  Y/CbCr 4:4:4  */
+#define V4L2_PIX_FMT_NV42    v4l2_fourcc('N', 'V', '4', '2') /* 24  Y/CrCb 4:4:4  */
 
 /* two non contiguous planes - one Y, one Cr + Cb interleaved  */
 #define V4L2_PIX_FMT_NV12M   v4l2_fourcc('N', 'M', '1', '2') /* 12  Y/CbCr 4:2:0  */
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH/RFC v2 3/3] fbdev: sh_mobile_lcdc: Support FOURCC-based format API
  2011-08-19  9:37 ` Laurent Pinchart
@ 2011-08-19  9:37   ` Laurent Pinchart
  -1 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-19  9:37 UTC (permalink / raw)
  To: linux-fbdev; +Cc: linux-media, magnus.damm

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 arch/arm/mach-shmobile/board-ag5evm.c   |    2 +-
 arch/arm/mach-shmobile/board-ap4evb.c   |    4 +-
 arch/arm/mach-shmobile/board-mackerel.c |    4 +-
 drivers/video/sh_mobile_lcdcfb.c        |  342 ++++++++++++++++++++-----------
 include/video/sh_mobile_lcdc.h          |    4 +-
 5 files changed, 230 insertions(+), 126 deletions(-)

diff --git a/arch/arm/mach-shmobile/board-ag5evm.c b/arch/arm/mach-shmobile/board-ag5evm.c
index ce5c251..e6dabaa 100644
--- a/arch/arm/mach-shmobile/board-ag5evm.c
+++ b/arch/arm/mach-shmobile/board-ag5evm.c
@@ -270,7 +270,7 @@ static struct sh_mobile_lcdc_info lcdc0_info = {
 		.flags = LCDC_FLAGS_DWPOL,
 		.lcd_size_cfg.width = 44,
 		.lcd_size_cfg.height = 79,
-		.bpp = 16,
+		.fourcc = V4L2_PIX_FMT_RGB565,
 		.lcd_cfg = lcdc0_modes,
 		.num_cfg = ARRAY_SIZE(lcdc0_modes),
 		.board_cfg = {
diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c
index 9e0856b..6f5db07 100644
--- a/arch/arm/mach-shmobile/board-ap4evb.c
+++ b/arch/arm/mach-shmobile/board-ap4evb.c
@@ -489,7 +489,7 @@ static struct sh_mobile_lcdc_info lcdc_info = {
 	.meram_dev = &meram_info,
 	.ch[0] = {
 		.chan = LCDC_CHAN_MAINLCD,
-		.bpp = 16,
+		.fourcc = V4L2_PIX_FMT_RGB565,
 		.lcd_cfg = ap4evb_lcdc_modes,
 		.num_cfg = ARRAY_SIZE(ap4evb_lcdc_modes),
 		.meram_cfg = &lcd_meram_cfg,
@@ -783,7 +783,7 @@ static struct sh_mobile_lcdc_info sh_mobile_lcdc1_info = {
 	.meram_dev = &meram_info,
 	.ch[0] = {
 		.chan = LCDC_CHAN_MAINLCD,
-		.bpp = 16,
+		.fourcc = V4L2_PIX_FMT_RGB565,
 		.interface_type = RGB24,
 		.clock_divider = 1,
 		.flags = LCDC_FLAGS_DWPOL,
diff --git a/arch/arm/mach-shmobile/board-mackerel.c b/arch/arm/mach-shmobile/board-mackerel.c
index 6e3c2df..6e36349 100644
--- a/arch/arm/mach-shmobile/board-mackerel.c
+++ b/arch/arm/mach-shmobile/board-mackerel.c
@@ -387,7 +387,7 @@ static struct sh_mobile_lcdc_info lcdc_info = {
 	.clock_source = LCDC_CLK_BUS,
 	.ch[0] = {
 		.chan = LCDC_CHAN_MAINLCD,
-		.bpp = 16,
+		.fourcc = V4L2_PIX_FMT_RGB565,
 		.lcd_cfg = mackerel_lcdc_modes,
 		.num_cfg = ARRAY_SIZE(mackerel_lcdc_modes),
 		.interface_type		= RGB24,
@@ -450,7 +450,7 @@ static struct sh_mobile_lcdc_info hdmi_lcdc_info = {
 	.clock_source = LCDC_CLK_EXTERNAL,
 	.ch[0] = {
 		.chan = LCDC_CHAN_MAINLCD,
-		.bpp = 16,
+		.fourcc = V4L2_PIX_FMT_RGB565,
 		.interface_type = RGB24,
 		.clock_divider = 1,
 		.flags = LCDC_FLAGS_DWPOL,
diff --git a/drivers/video/sh_mobile_lcdcfb.c b/drivers/video/sh_mobile_lcdcfb.c
index 97ab8ba..ea3f619 100644
--- a/drivers/video/sh_mobile_lcdcfb.c
+++ b/drivers/video/sh_mobile_lcdcfb.c
@@ -17,6 +17,7 @@
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
 #include <linux/interrupt.h>
+#include <linux/videodev2.h>
 #include <linux/vmalloc.h>
 #include <linux/ioctl.h>
 #include <linux/slab.h>
@@ -101,7 +102,7 @@ struct sh_mobile_lcdc_priv {
 	struct sh_mobile_lcdc_chan ch[2];
 	struct notifier_block notifier;
 	int started;
-	int forced_bpp; /* 2 channel LCDC must share bpp setting */
+	int forced_fourcc; /* 2 channel LCDC must share fourcc setting */
 	struct sh_mobile_meram_info *meram_dev;
 };
 
@@ -214,6 +215,42 @@ struct sh_mobile_lcdc_sys_bus_ops sh_mobile_lcdc_sys_bus_ops = {
 	lcdc_sys_read_data,
 };
 
+static int sh_mobile_format_fourcc(const struct fb_var_screeninfo *var)
+{
+	if (var->format.fourcc > 1)
+		return var->format.fourcc;
+
+	switch (var->bits_per_pixel) {
+	case 16:
+		return V4L2_PIX_FMT_RGB565;
+	case 24:
+		return V4L2_PIX_FMT_BGR24;
+	case 32:
+		return V4L2_PIX_FMT_BGR32;
+	default:
+		return 0;
+	}
+}
+
+static bool sh_mobile_format_yuv(const struct fb_var_screeninfo *var)
+{
+	if (var->format.fourcc <= 1)
+		return false;
+
+	switch (var->format.fourcc) {
+	case V4L2_PIX_FMT_NV12:
+	case V4L2_PIX_FMT_NV21:
+	case V4L2_PIX_FMT_NV16:
+	case V4L2_PIX_FMT_NV61:
+	case V4L2_PIX_FMT_NV24:
+	case V4L2_PIX_FMT_NV42:
+		return true;
+
+	default:
+		return false;
+	}
+}
+
 static void sh_mobile_lcdc_clk_on(struct sh_mobile_lcdc_priv *priv)
 {
 	if (atomic_inc_and_test(&priv->hw_usecnt)) {
@@ -434,7 +471,6 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
 {
 	struct sh_mobile_lcdc_chan *ch;
 	unsigned long tmp;
-	int bpp = 0;
 	int k, m;
 
 	/* Enable LCDC channels. Read data from external memory, avoid using the
@@ -453,9 +489,6 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
 		if (!ch->enabled)
 			continue;
 
-		if (!bpp)
-			bpp = ch->info->var.bits_per_pixel;
-
 		/* Power supply */
 		lcdc_write_chan(ch, LDPMR, 0);
 
@@ -486,31 +519,37 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
 
 		sh_mobile_lcdc_geometry(ch);
 
-		if (ch->info->var.nonstd) {
-			tmp = (ch->info->var.nonstd << 16);
-			switch (ch->info->var.bits_per_pixel) {
-			case 12:
-				tmp |= LDDFR_YF_420;
-				break;
-			case 16:
-				tmp |= LDDFR_YF_422;
-				break;
-			case 24:
-			default:
-				tmp |= LDDFR_YF_444;
-				break;
-			}
-		} else {
-			switch (ch->info->var.bits_per_pixel) {
-			case 16:
-				tmp = LDDFR_PKF_RGB16;
-				break;
-			case 24:
-				tmp = LDDFR_PKF_RGB24;
+		switch (sh_mobile_format_fourcc(&ch->info->var)) {
+		case V4L2_PIX_FMT_RGB565:
+			tmp = LDDFR_PKF_RGB16;
+			break;
+		case V4L2_PIX_FMT_BGR24:
+			tmp = LDDFR_PKF_RGB24;
+			break;
+		case V4L2_PIX_FMT_BGR32:
+			tmp = LDDFR_PKF_ARGB32;
+			break;
+		case V4L2_PIX_FMT_NV12:
+		case V4L2_PIX_FMT_NV21:
+			tmp = LDDFR_CC | LDDFR_YF_420;
+			break;
+		case V4L2_PIX_FMT_NV16:
+		case V4L2_PIX_FMT_NV61:
+			tmp = LDDFR_CC | LDDFR_YF_422;
+			break;
+		case V4L2_PIX_FMT_NV24:
+		case V4L2_PIX_FMT_NV42:
+			tmp = LDDFR_CC | LDDFR_YF_444;
+			break;
+		}
+
+		if (sh_mobile_format_yuv(&ch->info->var)) {
+			switch (ch->info->var.format.colorspace) {
+			case V4L2_COLORSPACE_REC709:
+				tmp |= LDDFR_CF1;
 				break;
-			case 32:
-			default:
-				tmp = LDDFR_PKF_ARGB32;
+			case V4L2_COLORSPACE_JPEG:
+				tmp |= LDDFR_CF0;
 				break;
 			}
 		}
@@ -518,7 +557,7 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
 		lcdc_write_chan(ch, LDDFR, tmp);
 		lcdc_write_chan(ch, LDMLSR, ch->pitch);
 		lcdc_write_chan(ch, LDSA1R, ch->base_addr_y);
-		if (ch->info->var.nonstd)
+		if (sh_mobile_format_yuv(&ch->info->var))
 			lcdc_write_chan(ch, LDSA2R, ch->base_addr_c);
 
 		/* When using deferred I/O mode, configure the LCDC for one-shot
@@ -535,21 +574,23 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
 	}
 
 	/* Word and long word swap. */
-	if  (priv->ch[0].info->var.nonstd)
+	switch (sh_mobile_format_fourcc(&priv->ch[0].info->var)) {
+	case V4L2_PIX_FMT_RGB565:
+	case V4L2_PIX_FMT_NV21:
+	case V4L2_PIX_FMT_NV61:
+	case V4L2_PIX_FMT_NV42:
+		tmp = LDDDSR_LS | LDDDSR_WS;
+		break;
+	case V4L2_PIX_FMT_BGR24:
+	case V4L2_PIX_FMT_NV12:
+	case V4L2_PIX_FMT_NV16:
+	case V4L2_PIX_FMT_NV24:
 		tmp = LDDDSR_LS | LDDDSR_WS | LDDDSR_BS;
-	else {
-		switch (bpp) {
-		case 16:
-			tmp = LDDDSR_LS | LDDDSR_WS;
-			break;
-		case 24:
-			tmp = LDDDSR_LS | LDDDSR_WS | LDDDSR_BS;
-			break;
-		case 32:
-		default:
-			tmp = LDDDSR_LS;
-			break;
-		}
+		break;
+	case V4L2_PIX_FMT_BGR32:
+	default:
+		tmp = LDDDSR_LS;
+		break;
 	}
 	lcdc_write(priv, _LDDDSR, tmp);
 
@@ -621,12 +662,24 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
 			ch->meram_enabled = 0;
 		}
 
-		if (!ch->info->var.nonstd)
-			pixelformat = SH_MOBILE_MERAM_PF_RGB;
-		else if (ch->info->var.bits_per_pixel == 24)
-			pixelformat = SH_MOBILE_MERAM_PF_NV24;
-		else
+		switch (sh_mobile_format_fourcc(&ch->info->var)) {
+		case V4L2_PIX_FMT_NV12:
+		case V4L2_PIX_FMT_NV21:
+		case V4L2_PIX_FMT_NV16:
+		case V4L2_PIX_FMT_NV61:
 			pixelformat = SH_MOBILE_MERAM_PF_NV;
+			break;
+		case V4L2_PIX_FMT_NV24:
+		case V4L2_PIX_FMT_NV42:
+			pixelformat = SH_MOBILE_MERAM_PF_NV24;
+			break;
+		case V4L2_PIX_FMT_RGB565:
+		case V4L2_PIX_FMT_BGR24:
+		case V4L2_PIX_FMT_BGR32:
+		default:
+			pixelformat = SH_MOBILE_MERAM_PF_RGB;
+			break;
+		}
 
 		ret = mdev->ops->meram_register(mdev, cfg, ch->pitch,
 					ch->info->var.yres, pixelformat,
@@ -844,6 +897,7 @@ static struct fb_fix_screeninfo sh_mobile_lcdc_fix  = {
 	.xpanstep =	0,
 	.ypanstep =	1,
 	.ywrapstep =	0,
+	.capabilities =	FB_CAP_FOURCC,
 };
 
 static void sh_mobile_lcdc_fillrect(struct fb_info *info,
@@ -876,8 +930,9 @@ static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var,
 	unsigned long new_pan_offset;
 	unsigned long base_addr_y, base_addr_c;
 	unsigned long c_offset;
+	bool yuv = sh_mobile_format_yuv(&info->var);
 
-	if (!info->var.nonstd)
+	if (!yuv)
 		new_pan_offset = var->yoffset * info->fix.line_length
 			       + var->xoffset * (info->var.bits_per_pixel / 8);
 	else
@@ -891,7 +946,7 @@ static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var,
 
 	/* Set the source address for the next refresh */
 	base_addr_y = ch->dma_handle + new_pan_offset;
-	if (info->var.nonstd) {
+	if (yuv) {
 		/* Set y offset */
 		c_offset = var->yoffset * info->fix.line_length
 			 * (info->var.bits_per_pixel - 8) / 8;
@@ -899,7 +954,7 @@ static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var,
 			    + info->var.xres * info->var.yres_virtual
 			    + c_offset;
 		/* Set x offset */
-		if (info->var.bits_per_pixel == 24)
+		if (sh_mobile_format_fourcc(&info->var) == V4L2_PIX_FMT_NV24)
 			base_addr_c += 2 * var->xoffset;
 		else
 			base_addr_c += var->xoffset;
@@ -923,7 +978,7 @@ static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var,
 	ch->base_addr_c = base_addr_c;
 
 	lcdc_write_chan_mirror(ch, LDSA1R, base_addr_y);
-	if (info->var.nonstd)
+	if (yuv)
 		lcdc_write_chan_mirror(ch, LDSA2R, base_addr_c);
 
 	if (lcdc_chan_is_sublcd(ch))
@@ -1099,51 +1154,78 @@ static int sh_mobile_check_var(struct fb_var_screeninfo *var, struct fb_info *in
 	if (var->yres_virtual < var->yres)
 		var->yres_virtual = var->yres;
 
-	if (var->bits_per_pixel <= 16) {		/* RGB 565 */
-		var->bits_per_pixel = 16;
-		var->red.offset = 11;
-		var->red.length = 5;
-		var->green.offset = 5;
-		var->green.length = 6;
-		var->blue.offset = 0;
-		var->blue.length = 5;
-		var->transp.offset = 0;
-		var->transp.length = 0;
-	} else if (var->bits_per_pixel <= 24) {		/* RGB 888 */
-		var->bits_per_pixel = 24;
-		var->red.offset = 16;
-		var->red.length = 8;
-		var->green.offset = 8;
-		var->green.length = 8;
-		var->blue.offset = 0;
-		var->blue.length = 8;
-		var->transp.offset = 0;
-		var->transp.length = 0;
-	} else if (var->bits_per_pixel <= 32) {		/* RGBA 888 */
-		var->bits_per_pixel = 32;
-		var->red.offset = 16;
-		var->red.length = 8;
-		var->green.offset = 8;
-		var->green.length = 8;
-		var->blue.offset = 0;
-		var->blue.length = 8;
-		var->transp.offset = 24;
-		var->transp.length = 8;
-	} else
-		return -EINVAL;
+	if (var->format.fourcc > 1) {
+		switch (var->format.fourcc) {
+		case V4L2_PIX_FMT_NV12:
+		case V4L2_PIX_FMT_NV21:
+			var->bits_per_pixel = 12;
+			break;
+		case V4L2_PIX_FMT_RGB565:
+		case V4L2_PIX_FMT_NV16:
+		case V4L2_PIX_FMT_NV61:
+			var->bits_per_pixel = 16;
+			break;
+		case V4L2_PIX_FMT_BGR24:
+		case V4L2_PIX_FMT_NV24:
+		case V4L2_PIX_FMT_NV42:
+			var->bits_per_pixel = 24;
+			break;
+		case V4L2_PIX_FMT_BGR32:
+			var->bits_per_pixel = 32;
+			break;
+		default:
+			return -EINVAL;
+		}
+
+		memset(var->format.reserved, 0, sizeof(var->format.reserved));
+	} else {
+		if (var->bits_per_pixel <= 16) {		/* RGB 565 */
+			var->bits_per_pixel = 16;
+			var->red.offset = 11;
+			var->red.length = 5;
+			var->green.offset = 5;
+			var->green.length = 6;
+			var->blue.offset = 0;
+			var->blue.length = 5;
+			var->transp.offset = 0;
+			var->transp.length = 0;
+		} else if (var->bits_per_pixel <= 24) {		/* RGB 888 */
+			var->bits_per_pixel = 24;
+			var->red.offset = 16;
+			var->red.length = 8;
+			var->green.offset = 8;
+			var->green.length = 8;
+			var->blue.offset = 0;
+			var->blue.length = 8;
+			var->transp.offset = 0;
+			var->transp.length = 0;
+		} else if (var->bits_per_pixel <= 32) {		/* RGBA 888 */
+			var->bits_per_pixel = 32;
+			var->red.offset = 16;
+			var->red.length = 8;
+			var->green.offset = 8;
+			var->green.length = 8;
+			var->blue.offset = 0;
+			var->blue.length = 8;
+			var->transp.offset = 24;
+			var->transp.length = 8;
+		} else
+			return -EINVAL;
 
-	var->red.msb_right = 0;
-	var->green.msb_right = 0;
-	var->blue.msb_right = 0;
-	var->transp.msb_right = 0;
+		var->red.msb_right = 0;
+		var->green.msb_right = 0;
+		var->blue.msb_right = 0;
+		var->transp.msb_right = 0;
+	}
 
 	/* Make sure we don't exceed our allocated memory. */
 	if (var->xres_virtual * var->yres_virtual * var->bits_per_pixel / 8 >
 	    info->fix.smem_len)
 		return -EINVAL;
 
-	/* only accept the forced_bpp for dual channel configurations */
-	if (p->forced_bpp && p->forced_bpp != var->bits_per_pixel)
+	/* only accept the forced_fourcc for dual channel configurations */
+	if (p->forced_fourcc &&
+	    p->forced_fourcc != sh_mobile_format_fourcc(var))
 		return -EINVAL;
 
 	return 0;
@@ -1157,7 +1239,7 @@ static int sh_mobile_set_par(struct fb_info *info)
 
 	sh_mobile_lcdc_stop(ch->lcdc);
 
-	if (info->var.nonstd)
+	if (sh_mobile_format_yuv(&info->var))
 		info->fix.line_length = info->var.xres;
 	else
 		info->fix.line_length = info->var.xres
@@ -1169,6 +1251,11 @@ static int sh_mobile_set_par(struct fb_info *info)
 		info->fix.line_length = line_length;
 	}
 
+	if (info->var.format.fourcc > 1)
+		info->fix.visual = FB_VISUAL_FOURCC;
+	else
+		info->fix.visual = FB_VISUAL_TRUECOLOR;
+
 	return ret;
 }
 
@@ -1463,9 +1550,9 @@ static int __devinit sh_mobile_lcdc_channel_init(struct sh_mobile_lcdc_chan *ch,
 	for (i = 0, mode = cfg->lcd_cfg; i < cfg->num_cfg; i++, mode++) {
 		unsigned int size = mode->yres * mode->xres;
 
-		/* NV12 buffers must have even number of lines */
-		if ((cfg->nonstd) && cfg->bpp == 12 &&
-				(mode->yres & 0x1)) {
+		/* NV12/NV21 buffers must have even number of lines */
+		if ((cfg->fourcc == V4L2_PIX_FMT_NV12 ||
+		     cfg->fourcc == V4L2_PIX_FMT_NV21) && (mode->yres & 0x1)) {
 			dev_err(dev, "yres must be multiple of 2 for YCbCr420 "
 				"mode.\n");
 			return -EINVAL;
@@ -1483,14 +1570,6 @@ static int __devinit sh_mobile_lcdc_channel_init(struct sh_mobile_lcdc_chan *ch,
 		dev_dbg(dev, "Found largest videomode %ux%u\n",
 			max_mode->xres, max_mode->yres);
 
-	/* Initialize fixed screen information. Restrict pan to 2 lines steps
-	 * for NV12.
-	 */
-	info->fix = sh_mobile_lcdc_fix;
-	info->fix.smem_len = max_size * 2 * cfg->bpp / 8;
-	if (cfg->nonstd && cfg->bpp == 12)
-		info->fix.ypanstep = 2;
-
 	/* Create the mode list. */
 	if (cfg->lcd_cfg == NULL) {
 		mode = &default_720p;
@@ -1508,19 +1587,38 @@ static int __devinit sh_mobile_lcdc_channel_init(struct sh_mobile_lcdc_chan *ch,
 	 */
 	var = &info->var;
 	fb_videomode_to_var(var, mode);
-	var->bits_per_pixel = cfg->bpp;
 	var->width = cfg->lcd_size_cfg.width;
 	var->height = cfg->lcd_size_cfg.height;
 	var->yres_virtual = var->yres * 2;
 	var->activate = FB_ACTIVATE_NOW;
 
+	switch (cfg->fourcc) {
+	case V4L2_PIX_FMT_RGB565:
+		var->bits_per_pixel = 16;
+		break;
+	case V4L2_PIX_FMT_BGR24:
+		var->bits_per_pixel = 24;
+		break;
+	case V4L2_PIX_FMT_BGR32:
+		var->bits_per_pixel = 32;
+		break;
+	default:
+		var->format.fourcc = cfg->fourcc;
+		break;
+	}
+
+	/* Make sure the memory size check won't fail. smem_len is initialized
+	 * later based on var.
+	 */
+	info->fix.smem_len = UINT_MAX;
 	ret = sh_mobile_check_var(var, info);
 	if (ret)
 		return ret;
 
+	max_size *= var->bits_per_pixel / 8 * 2;
+
 	/* Allocate frame buffer memory and color map. */
-	buf = dma_alloc_coherent(dev, info->fix.smem_len, &ch->dma_handle,
-				 GFP_KERNEL);
+	buf = dma_alloc_coherent(dev, max_size, &ch->dma_handle, GFP_KERNEL);
 	if (!buf) {
 		dev_err(dev, "unable to allocate buffer\n");
 		return -ENOMEM;
@@ -1529,16 +1627,25 @@ static int __devinit sh_mobile_lcdc_channel_init(struct sh_mobile_lcdc_chan *ch,
 	ret = fb_alloc_cmap(&info->cmap, PALETTE_NR, 0);
 	if (ret < 0) {
 		dev_err(dev, "unable to allocate cmap\n");
-		dma_free_coherent(dev, info->fix.smem_len,
-				  buf, ch->dma_handle);
+		dma_free_coherent(dev, max_size, buf, ch->dma_handle);
 		return ret;
 	}
 
+	/* Initialize fixed screen information. Restrict pan to 2 lines steps
+	 * for NV12 and NV21.
+	 */
+	info->fix = sh_mobile_lcdc_fix;
 	info->fix.smem_start = ch->dma_handle;
-	if (var->nonstd)
+	info->fix.smem_len = max_size * var->bits_per_pixel / 8 * 2;
+	if (cfg->fourcc == V4L2_PIX_FMT_NV12 ||
+	    cfg->fourcc == V4L2_PIX_FMT_NV21)
+		info->fix.ypanstep = 2;
+
+	if (sh_mobile_format_yuv(var))
 		info->fix.line_length = var->xres;
 	else
-		info->fix.line_length = var->xres * (cfg->bpp / 8);
+		info->fix.line_length = var->xres * var->bits_per_pixel
+				      / 8;
 
 	info->screen_base = buf;
 	info->device = dev;
@@ -1625,9 +1732,9 @@ static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev)
 		goto err1;
 	}
 
-	/* for dual channel LCDC (MAIN + SUB) force shared bpp setting */
+	/* for dual channel LCDC (MAIN + SUB) force shared format setting */
 	if (num_channels == 2)
-		priv->forced_bpp = pdata->ch[0].bpp;
+		priv->forced_fourcc = pdata->ch[0].fourcc;
 
 	priv->base = ioremap_nocache(res->start, resource_size(res));
 	if (!priv->base)
@@ -1674,13 +1781,10 @@ static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev)
 		if (error < 0)
 			goto err1;
 
-		dev_info(info->dev,
-			 "registered %s/%s as %dx%d %dbpp.\n",
-			 pdev->name,
-			 (ch->cfg.chan == LCDC_CHAN_MAINLCD) ?
-			 "mainlcd" : "sublcd",
-			 info->var.xres, info->var.yres,
-			 ch->cfg.bpp);
+		dev_info(info->dev, "registered %s/%s as %dx%d %dbpp.\n",
+			 pdev->name, (ch->cfg.chan == LCDC_CHAN_MAINLCD) ?
+			 "mainlcd" : "sublcd", info->var.xres, info->var.yres,
+			 info->var.bits_per_pixel);
 
 		/* deferred io mode: disable clock to save power */
 		if (info->fbdefio || info->state == FBINFO_STATE_SUSPENDED)
diff --git a/include/video/sh_mobile_lcdc.h b/include/video/sh_mobile_lcdc.h
index 8101b72..fe30b75 100644
--- a/include/video/sh_mobile_lcdc.h
+++ b/include/video/sh_mobile_lcdc.h
@@ -174,7 +174,8 @@ struct sh_mobile_lcdc_bl_info {
 
 struct sh_mobile_lcdc_chan_cfg {
 	int chan;
-	int bpp;
+	int fourcc;
+	int colorspace;
 	int interface_type; /* selects RGBn or SYSn I/F, see above */
 	int clock_divider;
 	unsigned long flags; /* LCDC_FLAGS_... */
@@ -184,7 +185,6 @@ struct sh_mobile_lcdc_chan_cfg {
 	struct sh_mobile_lcdc_board_cfg board_cfg;
 	struct sh_mobile_lcdc_bl_info bl_info;
 	struct sh_mobile_lcdc_sys_bus_cfg sys_bus_cfg; /* only for SYSn I/F */
-	int nonstd;
 	struct sh_mobile_meram_cfg *meram_cfg;
 };
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH/RFC v2 3/3] fbdev: sh_mobile_lcdc: Support FOURCC-based format API
@ 2011-08-19  9:37   ` Laurent Pinchart
  0 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-19  9:37 UTC (permalink / raw)
  To: linux-fbdev; +Cc: linux-media, magnus.damm

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 arch/arm/mach-shmobile/board-ag5evm.c   |    2 +-
 arch/arm/mach-shmobile/board-ap4evb.c   |    4 +-
 arch/arm/mach-shmobile/board-mackerel.c |    4 +-
 drivers/video/sh_mobile_lcdcfb.c        |  342 ++++++++++++++++++++-----------
 include/video/sh_mobile_lcdc.h          |    4 +-
 5 files changed, 230 insertions(+), 126 deletions(-)

diff --git a/arch/arm/mach-shmobile/board-ag5evm.c b/arch/arm/mach-shmobile/board-ag5evm.c
index ce5c251..e6dabaa 100644
--- a/arch/arm/mach-shmobile/board-ag5evm.c
+++ b/arch/arm/mach-shmobile/board-ag5evm.c
@@ -270,7 +270,7 @@ static struct sh_mobile_lcdc_info lcdc0_info = {
 		.flags = LCDC_FLAGS_DWPOL,
 		.lcd_size_cfg.width = 44,
 		.lcd_size_cfg.height = 79,
-		.bpp = 16,
+		.fourcc = V4L2_PIX_FMT_RGB565,
 		.lcd_cfg = lcdc0_modes,
 		.num_cfg = ARRAY_SIZE(lcdc0_modes),
 		.board_cfg = {
diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c
index 9e0856b..6f5db07 100644
--- a/arch/arm/mach-shmobile/board-ap4evb.c
+++ b/arch/arm/mach-shmobile/board-ap4evb.c
@@ -489,7 +489,7 @@ static struct sh_mobile_lcdc_info lcdc_info = {
 	.meram_dev = &meram_info,
 	.ch[0] = {
 		.chan = LCDC_CHAN_MAINLCD,
-		.bpp = 16,
+		.fourcc = V4L2_PIX_FMT_RGB565,
 		.lcd_cfg = ap4evb_lcdc_modes,
 		.num_cfg = ARRAY_SIZE(ap4evb_lcdc_modes),
 		.meram_cfg = &lcd_meram_cfg,
@@ -783,7 +783,7 @@ static struct sh_mobile_lcdc_info sh_mobile_lcdc1_info = {
 	.meram_dev = &meram_info,
 	.ch[0] = {
 		.chan = LCDC_CHAN_MAINLCD,
-		.bpp = 16,
+		.fourcc = V4L2_PIX_FMT_RGB565,
 		.interface_type = RGB24,
 		.clock_divider = 1,
 		.flags = LCDC_FLAGS_DWPOL,
diff --git a/arch/arm/mach-shmobile/board-mackerel.c b/arch/arm/mach-shmobile/board-mackerel.c
index 6e3c2df..6e36349 100644
--- a/arch/arm/mach-shmobile/board-mackerel.c
+++ b/arch/arm/mach-shmobile/board-mackerel.c
@@ -387,7 +387,7 @@ static struct sh_mobile_lcdc_info lcdc_info = {
 	.clock_source = LCDC_CLK_BUS,
 	.ch[0] = {
 		.chan = LCDC_CHAN_MAINLCD,
-		.bpp = 16,
+		.fourcc = V4L2_PIX_FMT_RGB565,
 		.lcd_cfg = mackerel_lcdc_modes,
 		.num_cfg = ARRAY_SIZE(mackerel_lcdc_modes),
 		.interface_type		= RGB24,
@@ -450,7 +450,7 @@ static struct sh_mobile_lcdc_info hdmi_lcdc_info = {
 	.clock_source = LCDC_CLK_EXTERNAL,
 	.ch[0] = {
 		.chan = LCDC_CHAN_MAINLCD,
-		.bpp = 16,
+		.fourcc = V4L2_PIX_FMT_RGB565,
 		.interface_type = RGB24,
 		.clock_divider = 1,
 		.flags = LCDC_FLAGS_DWPOL,
diff --git a/drivers/video/sh_mobile_lcdcfb.c b/drivers/video/sh_mobile_lcdcfb.c
index 97ab8ba..ea3f619 100644
--- a/drivers/video/sh_mobile_lcdcfb.c
+++ b/drivers/video/sh_mobile_lcdcfb.c
@@ -17,6 +17,7 @@
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
 #include <linux/interrupt.h>
+#include <linux/videodev2.h>
 #include <linux/vmalloc.h>
 #include <linux/ioctl.h>
 #include <linux/slab.h>
@@ -101,7 +102,7 @@ struct sh_mobile_lcdc_priv {
 	struct sh_mobile_lcdc_chan ch[2];
 	struct notifier_block notifier;
 	int started;
-	int forced_bpp; /* 2 channel LCDC must share bpp setting */
+	int forced_fourcc; /* 2 channel LCDC must share fourcc setting */
 	struct sh_mobile_meram_info *meram_dev;
 };
 
@@ -214,6 +215,42 @@ struct sh_mobile_lcdc_sys_bus_ops sh_mobile_lcdc_sys_bus_ops = {
 	lcdc_sys_read_data,
 };
 
+static int sh_mobile_format_fourcc(const struct fb_var_screeninfo *var)
+{
+	if (var->format.fourcc > 1)
+		return var->format.fourcc;
+
+	switch (var->bits_per_pixel) {
+	case 16:
+		return V4L2_PIX_FMT_RGB565;
+	case 24:
+		return V4L2_PIX_FMT_BGR24;
+	case 32:
+		return V4L2_PIX_FMT_BGR32;
+	default:
+		return 0;
+	}
+}
+
+static bool sh_mobile_format_yuv(const struct fb_var_screeninfo *var)
+{
+	if (var->format.fourcc <= 1)
+		return false;
+
+	switch (var->format.fourcc) {
+	case V4L2_PIX_FMT_NV12:
+	case V4L2_PIX_FMT_NV21:
+	case V4L2_PIX_FMT_NV16:
+	case V4L2_PIX_FMT_NV61:
+	case V4L2_PIX_FMT_NV24:
+	case V4L2_PIX_FMT_NV42:
+		return true;
+
+	default:
+		return false;
+	}
+}
+
 static void sh_mobile_lcdc_clk_on(struct sh_mobile_lcdc_priv *priv)
 {
 	if (atomic_inc_and_test(&priv->hw_usecnt)) {
@@ -434,7 +471,6 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
 {
 	struct sh_mobile_lcdc_chan *ch;
 	unsigned long tmp;
-	int bpp = 0;
 	int k, m;
 
 	/* Enable LCDC channels. Read data from external memory, avoid using the
@@ -453,9 +489,6 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
 		if (!ch->enabled)
 			continue;
 
-		if (!bpp)
-			bpp = ch->info->var.bits_per_pixel;
-
 		/* Power supply */
 		lcdc_write_chan(ch, LDPMR, 0);
 
@@ -486,31 +519,37 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
 
 		sh_mobile_lcdc_geometry(ch);
 
-		if (ch->info->var.nonstd) {
-			tmp = (ch->info->var.nonstd << 16);
-			switch (ch->info->var.bits_per_pixel) {
-			case 12:
-				tmp |= LDDFR_YF_420;
-				break;
-			case 16:
-				tmp |= LDDFR_YF_422;
-				break;
-			case 24:
-			default:
-				tmp |= LDDFR_YF_444;
-				break;
-			}
-		} else {
-			switch (ch->info->var.bits_per_pixel) {
-			case 16:
-				tmp = LDDFR_PKF_RGB16;
-				break;
-			case 24:
-				tmp = LDDFR_PKF_RGB24;
+		switch (sh_mobile_format_fourcc(&ch->info->var)) {
+		case V4L2_PIX_FMT_RGB565:
+			tmp = LDDFR_PKF_RGB16;
+			break;
+		case V4L2_PIX_FMT_BGR24:
+			tmp = LDDFR_PKF_RGB24;
+			break;
+		case V4L2_PIX_FMT_BGR32:
+			tmp = LDDFR_PKF_ARGB32;
+			break;
+		case V4L2_PIX_FMT_NV12:
+		case V4L2_PIX_FMT_NV21:
+			tmp = LDDFR_CC | LDDFR_YF_420;
+			break;
+		case V4L2_PIX_FMT_NV16:
+		case V4L2_PIX_FMT_NV61:
+			tmp = LDDFR_CC | LDDFR_YF_422;
+			break;
+		case V4L2_PIX_FMT_NV24:
+		case V4L2_PIX_FMT_NV42:
+			tmp = LDDFR_CC | LDDFR_YF_444;
+			break;
+		}
+
+		if (sh_mobile_format_yuv(&ch->info->var)) {
+			switch (ch->info->var.format.colorspace) {
+			case V4L2_COLORSPACE_REC709:
+				tmp |= LDDFR_CF1;
 				break;
-			case 32:
-			default:
-				tmp = LDDFR_PKF_ARGB32;
+			case V4L2_COLORSPACE_JPEG:
+				tmp |= LDDFR_CF0;
 				break;
 			}
 		}
@@ -518,7 +557,7 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
 		lcdc_write_chan(ch, LDDFR, tmp);
 		lcdc_write_chan(ch, LDMLSR, ch->pitch);
 		lcdc_write_chan(ch, LDSA1R, ch->base_addr_y);
-		if (ch->info->var.nonstd)
+		if (sh_mobile_format_yuv(&ch->info->var))
 			lcdc_write_chan(ch, LDSA2R, ch->base_addr_c);
 
 		/* When using deferred I/O mode, configure the LCDC for one-shot
@@ -535,21 +574,23 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
 	}
 
 	/* Word and long word swap. */
-	if  (priv->ch[0].info->var.nonstd)
+	switch (sh_mobile_format_fourcc(&priv->ch[0].info->var)) {
+	case V4L2_PIX_FMT_RGB565:
+	case V4L2_PIX_FMT_NV21:
+	case V4L2_PIX_FMT_NV61:
+	case V4L2_PIX_FMT_NV42:
+		tmp = LDDDSR_LS | LDDDSR_WS;
+		break;
+	case V4L2_PIX_FMT_BGR24:
+	case V4L2_PIX_FMT_NV12:
+	case V4L2_PIX_FMT_NV16:
+	case V4L2_PIX_FMT_NV24:
 		tmp = LDDDSR_LS | LDDDSR_WS | LDDDSR_BS;
-	else {
-		switch (bpp) {
-		case 16:
-			tmp = LDDDSR_LS | LDDDSR_WS;
-			break;
-		case 24:
-			tmp = LDDDSR_LS | LDDDSR_WS | LDDDSR_BS;
-			break;
-		case 32:
-		default:
-			tmp = LDDDSR_LS;
-			break;
-		}
+		break;
+	case V4L2_PIX_FMT_BGR32:
+	default:
+		tmp = LDDDSR_LS;
+		break;
 	}
 	lcdc_write(priv, _LDDDSR, tmp);
 
@@ -621,12 +662,24 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
 			ch->meram_enabled = 0;
 		}
 
-		if (!ch->info->var.nonstd)
-			pixelformat = SH_MOBILE_MERAM_PF_RGB;
-		else if (ch->info->var.bits_per_pixel = 24)
-			pixelformat = SH_MOBILE_MERAM_PF_NV24;
-		else
+		switch (sh_mobile_format_fourcc(&ch->info->var)) {
+		case V4L2_PIX_FMT_NV12:
+		case V4L2_PIX_FMT_NV21:
+		case V4L2_PIX_FMT_NV16:
+		case V4L2_PIX_FMT_NV61:
 			pixelformat = SH_MOBILE_MERAM_PF_NV;
+			break;
+		case V4L2_PIX_FMT_NV24:
+		case V4L2_PIX_FMT_NV42:
+			pixelformat = SH_MOBILE_MERAM_PF_NV24;
+			break;
+		case V4L2_PIX_FMT_RGB565:
+		case V4L2_PIX_FMT_BGR24:
+		case V4L2_PIX_FMT_BGR32:
+		default:
+			pixelformat = SH_MOBILE_MERAM_PF_RGB;
+			break;
+		}
 
 		ret = mdev->ops->meram_register(mdev, cfg, ch->pitch,
 					ch->info->var.yres, pixelformat,
@@ -844,6 +897,7 @@ static struct fb_fix_screeninfo sh_mobile_lcdc_fix  = {
 	.xpanstep =	0,
 	.ypanstep =	1,
 	.ywrapstep =	0,
+	.capabilities =	FB_CAP_FOURCC,
 };
 
 static void sh_mobile_lcdc_fillrect(struct fb_info *info,
@@ -876,8 +930,9 @@ static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var,
 	unsigned long new_pan_offset;
 	unsigned long base_addr_y, base_addr_c;
 	unsigned long c_offset;
+	bool yuv = sh_mobile_format_yuv(&info->var);
 
-	if (!info->var.nonstd)
+	if (!yuv)
 		new_pan_offset = var->yoffset * info->fix.line_length
 			       + var->xoffset * (info->var.bits_per_pixel / 8);
 	else
@@ -891,7 +946,7 @@ static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var,
 
 	/* Set the source address for the next refresh */
 	base_addr_y = ch->dma_handle + new_pan_offset;
-	if (info->var.nonstd) {
+	if (yuv) {
 		/* Set y offset */
 		c_offset = var->yoffset * info->fix.line_length
 			 * (info->var.bits_per_pixel - 8) / 8;
@@ -899,7 +954,7 @@ static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var,
 			    + info->var.xres * info->var.yres_virtual
 			    + c_offset;
 		/* Set x offset */
-		if (info->var.bits_per_pixel = 24)
+		if (sh_mobile_format_fourcc(&info->var) = V4L2_PIX_FMT_NV24)
 			base_addr_c += 2 * var->xoffset;
 		else
 			base_addr_c += var->xoffset;
@@ -923,7 +978,7 @@ static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var,
 	ch->base_addr_c = base_addr_c;
 
 	lcdc_write_chan_mirror(ch, LDSA1R, base_addr_y);
-	if (info->var.nonstd)
+	if (yuv)
 		lcdc_write_chan_mirror(ch, LDSA2R, base_addr_c);
 
 	if (lcdc_chan_is_sublcd(ch))
@@ -1099,51 +1154,78 @@ static int sh_mobile_check_var(struct fb_var_screeninfo *var, struct fb_info *in
 	if (var->yres_virtual < var->yres)
 		var->yres_virtual = var->yres;
 
-	if (var->bits_per_pixel <= 16) {		/* RGB 565 */
-		var->bits_per_pixel = 16;
-		var->red.offset = 11;
-		var->red.length = 5;
-		var->green.offset = 5;
-		var->green.length = 6;
-		var->blue.offset = 0;
-		var->blue.length = 5;
-		var->transp.offset = 0;
-		var->transp.length = 0;
-	} else if (var->bits_per_pixel <= 24) {		/* RGB 888 */
-		var->bits_per_pixel = 24;
-		var->red.offset = 16;
-		var->red.length = 8;
-		var->green.offset = 8;
-		var->green.length = 8;
-		var->blue.offset = 0;
-		var->blue.length = 8;
-		var->transp.offset = 0;
-		var->transp.length = 0;
-	} else if (var->bits_per_pixel <= 32) {		/* RGBA 888 */
-		var->bits_per_pixel = 32;
-		var->red.offset = 16;
-		var->red.length = 8;
-		var->green.offset = 8;
-		var->green.length = 8;
-		var->blue.offset = 0;
-		var->blue.length = 8;
-		var->transp.offset = 24;
-		var->transp.length = 8;
-	} else
-		return -EINVAL;
+	if (var->format.fourcc > 1) {
+		switch (var->format.fourcc) {
+		case V4L2_PIX_FMT_NV12:
+		case V4L2_PIX_FMT_NV21:
+			var->bits_per_pixel = 12;
+			break;
+		case V4L2_PIX_FMT_RGB565:
+		case V4L2_PIX_FMT_NV16:
+		case V4L2_PIX_FMT_NV61:
+			var->bits_per_pixel = 16;
+			break;
+		case V4L2_PIX_FMT_BGR24:
+		case V4L2_PIX_FMT_NV24:
+		case V4L2_PIX_FMT_NV42:
+			var->bits_per_pixel = 24;
+			break;
+		case V4L2_PIX_FMT_BGR32:
+			var->bits_per_pixel = 32;
+			break;
+		default:
+			return -EINVAL;
+		}
+
+		memset(var->format.reserved, 0, sizeof(var->format.reserved));
+	} else {
+		if (var->bits_per_pixel <= 16) {		/* RGB 565 */
+			var->bits_per_pixel = 16;
+			var->red.offset = 11;
+			var->red.length = 5;
+			var->green.offset = 5;
+			var->green.length = 6;
+			var->blue.offset = 0;
+			var->blue.length = 5;
+			var->transp.offset = 0;
+			var->transp.length = 0;
+		} else if (var->bits_per_pixel <= 24) {		/* RGB 888 */
+			var->bits_per_pixel = 24;
+			var->red.offset = 16;
+			var->red.length = 8;
+			var->green.offset = 8;
+			var->green.length = 8;
+			var->blue.offset = 0;
+			var->blue.length = 8;
+			var->transp.offset = 0;
+			var->transp.length = 0;
+		} else if (var->bits_per_pixel <= 32) {		/* RGBA 888 */
+			var->bits_per_pixel = 32;
+			var->red.offset = 16;
+			var->red.length = 8;
+			var->green.offset = 8;
+			var->green.length = 8;
+			var->blue.offset = 0;
+			var->blue.length = 8;
+			var->transp.offset = 24;
+			var->transp.length = 8;
+		} else
+			return -EINVAL;
 
-	var->red.msb_right = 0;
-	var->green.msb_right = 0;
-	var->blue.msb_right = 0;
-	var->transp.msb_right = 0;
+		var->red.msb_right = 0;
+		var->green.msb_right = 0;
+		var->blue.msb_right = 0;
+		var->transp.msb_right = 0;
+	}
 
 	/* Make sure we don't exceed our allocated memory. */
 	if (var->xres_virtual * var->yres_virtual * var->bits_per_pixel / 8 >
 	    info->fix.smem_len)
 		return -EINVAL;
 
-	/* only accept the forced_bpp for dual channel configurations */
-	if (p->forced_bpp && p->forced_bpp != var->bits_per_pixel)
+	/* only accept the forced_fourcc for dual channel configurations */
+	if (p->forced_fourcc &&
+	    p->forced_fourcc != sh_mobile_format_fourcc(var))
 		return -EINVAL;
 
 	return 0;
@@ -1157,7 +1239,7 @@ static int sh_mobile_set_par(struct fb_info *info)
 
 	sh_mobile_lcdc_stop(ch->lcdc);
 
-	if (info->var.nonstd)
+	if (sh_mobile_format_yuv(&info->var))
 		info->fix.line_length = info->var.xres;
 	else
 		info->fix.line_length = info->var.xres
@@ -1169,6 +1251,11 @@ static int sh_mobile_set_par(struct fb_info *info)
 		info->fix.line_length = line_length;
 	}
 
+	if (info->var.format.fourcc > 1)
+		info->fix.visual = FB_VISUAL_FOURCC;
+	else
+		info->fix.visual = FB_VISUAL_TRUECOLOR;
+
 	return ret;
 }
 
@@ -1463,9 +1550,9 @@ static int __devinit sh_mobile_lcdc_channel_init(struct sh_mobile_lcdc_chan *ch,
 	for (i = 0, mode = cfg->lcd_cfg; i < cfg->num_cfg; i++, mode++) {
 		unsigned int size = mode->yres * mode->xres;
 
-		/* NV12 buffers must have even number of lines */
-		if ((cfg->nonstd) && cfg->bpp = 12 &&
-				(mode->yres & 0x1)) {
+		/* NV12/NV21 buffers must have even number of lines */
+		if ((cfg->fourcc = V4L2_PIX_FMT_NV12 ||
+		     cfg->fourcc = V4L2_PIX_FMT_NV21) && (mode->yres & 0x1)) {
 			dev_err(dev, "yres must be multiple of 2 for YCbCr420 "
 				"mode.\n");
 			return -EINVAL;
@@ -1483,14 +1570,6 @@ static int __devinit sh_mobile_lcdc_channel_init(struct sh_mobile_lcdc_chan *ch,
 		dev_dbg(dev, "Found largest videomode %ux%u\n",
 			max_mode->xres, max_mode->yres);
 
-	/* Initialize fixed screen information. Restrict pan to 2 lines steps
-	 * for NV12.
-	 */
-	info->fix = sh_mobile_lcdc_fix;
-	info->fix.smem_len = max_size * 2 * cfg->bpp / 8;
-	if (cfg->nonstd && cfg->bpp = 12)
-		info->fix.ypanstep = 2;
-
 	/* Create the mode list. */
 	if (cfg->lcd_cfg = NULL) {
 		mode = &default_720p;
@@ -1508,19 +1587,38 @@ static int __devinit sh_mobile_lcdc_channel_init(struct sh_mobile_lcdc_chan *ch,
 	 */
 	var = &info->var;
 	fb_videomode_to_var(var, mode);
-	var->bits_per_pixel = cfg->bpp;
 	var->width = cfg->lcd_size_cfg.width;
 	var->height = cfg->lcd_size_cfg.height;
 	var->yres_virtual = var->yres * 2;
 	var->activate = FB_ACTIVATE_NOW;
 
+	switch (cfg->fourcc) {
+	case V4L2_PIX_FMT_RGB565:
+		var->bits_per_pixel = 16;
+		break;
+	case V4L2_PIX_FMT_BGR24:
+		var->bits_per_pixel = 24;
+		break;
+	case V4L2_PIX_FMT_BGR32:
+		var->bits_per_pixel = 32;
+		break;
+	default:
+		var->format.fourcc = cfg->fourcc;
+		break;
+	}
+
+	/* Make sure the memory size check won't fail. smem_len is initialized
+	 * later based on var.
+	 */
+	info->fix.smem_len = UINT_MAX;
 	ret = sh_mobile_check_var(var, info);
 	if (ret)
 		return ret;
 
+	max_size *= var->bits_per_pixel / 8 * 2;
+
 	/* Allocate frame buffer memory and color map. */
-	buf = dma_alloc_coherent(dev, info->fix.smem_len, &ch->dma_handle,
-				 GFP_KERNEL);
+	buf = dma_alloc_coherent(dev, max_size, &ch->dma_handle, GFP_KERNEL);
 	if (!buf) {
 		dev_err(dev, "unable to allocate buffer\n");
 		return -ENOMEM;
@@ -1529,16 +1627,25 @@ static int __devinit sh_mobile_lcdc_channel_init(struct sh_mobile_lcdc_chan *ch,
 	ret = fb_alloc_cmap(&info->cmap, PALETTE_NR, 0);
 	if (ret < 0) {
 		dev_err(dev, "unable to allocate cmap\n");
-		dma_free_coherent(dev, info->fix.smem_len,
-				  buf, ch->dma_handle);
+		dma_free_coherent(dev, max_size, buf, ch->dma_handle);
 		return ret;
 	}
 
+	/* Initialize fixed screen information. Restrict pan to 2 lines steps
+	 * for NV12 and NV21.
+	 */
+	info->fix = sh_mobile_lcdc_fix;
 	info->fix.smem_start = ch->dma_handle;
-	if (var->nonstd)
+	info->fix.smem_len = max_size * var->bits_per_pixel / 8 * 2;
+	if (cfg->fourcc = V4L2_PIX_FMT_NV12 ||
+	    cfg->fourcc = V4L2_PIX_FMT_NV21)
+		info->fix.ypanstep = 2;
+
+	if (sh_mobile_format_yuv(var))
 		info->fix.line_length = var->xres;
 	else
-		info->fix.line_length = var->xres * (cfg->bpp / 8);
+		info->fix.line_length = var->xres * var->bits_per_pixel
+				      / 8;
 
 	info->screen_base = buf;
 	info->device = dev;
@@ -1625,9 +1732,9 @@ static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev)
 		goto err1;
 	}
 
-	/* for dual channel LCDC (MAIN + SUB) force shared bpp setting */
+	/* for dual channel LCDC (MAIN + SUB) force shared format setting */
 	if (num_channels = 2)
-		priv->forced_bpp = pdata->ch[0].bpp;
+		priv->forced_fourcc = pdata->ch[0].fourcc;
 
 	priv->base = ioremap_nocache(res->start, resource_size(res));
 	if (!priv->base)
@@ -1674,13 +1781,10 @@ static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev)
 		if (error < 0)
 			goto err1;
 
-		dev_info(info->dev,
-			 "registered %s/%s as %dx%d %dbpp.\n",
-			 pdev->name,
-			 (ch->cfg.chan = LCDC_CHAN_MAINLCD) ?
-			 "mainlcd" : "sublcd",
-			 info->var.xres, info->var.yres,
-			 ch->cfg.bpp);
+		dev_info(info->dev, "registered %s/%s as %dx%d %dbpp.\n",
+			 pdev->name, (ch->cfg.chan = LCDC_CHAN_MAINLCD) ?
+			 "mainlcd" : "sublcd", info->var.xres, info->var.yres,
+			 info->var.bits_per_pixel);
 
 		/* deferred io mode: disable clock to save power */
 		if (info->fbdefio || info->state = FBINFO_STATE_SUSPENDED)
diff --git a/include/video/sh_mobile_lcdc.h b/include/video/sh_mobile_lcdc.h
index 8101b72..fe30b75 100644
--- a/include/video/sh_mobile_lcdc.h
+++ b/include/video/sh_mobile_lcdc.h
@@ -174,7 +174,8 @@ struct sh_mobile_lcdc_bl_info {
 
 struct sh_mobile_lcdc_chan_cfg {
 	int chan;
-	int bpp;
+	int fourcc;
+	int colorspace;
 	int interface_type; /* selects RGBn or SYSn I/F, see above */
 	int clock_divider;
 	unsigned long flags; /* LCDC_FLAGS_... */
@@ -184,7 +185,6 @@ struct sh_mobile_lcdc_chan_cfg {
 	struct sh_mobile_lcdc_board_cfg board_cfg;
 	struct sh_mobile_lcdc_bl_info bl_info;
 	struct sh_mobile_lcdc_sys_bus_cfg sys_bus_cfg; /* only for SYSn I/F */
-	int nonstd;
 	struct sh_mobile_meram_cfg *meram_cfg;
 };
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
  2011-08-19  9:37   ` Laurent Pinchart
@ 2011-08-26 17:07     ` Florian Tobias Schandinat
  -1 siblings, 0 replies; 52+ messages in thread
From: Florian Tobias Schandinat @ 2011-08-26 17:07 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Laurent,

hope we're close to the final thing now. Just a few minor issues.

On 08/19/2011 09:37 AM, Laurent Pinchart wrote:
> This API will be used to support YUV frame buffer formats in a standard
> way.
> 
> Last but not least, create a much needed fbdev API documentation and
> document the format setting APIs.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  Documentation/fb/api.txt |  299 ++++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/fb.h       |   27 ++++-
>  2 files changed, 320 insertions(+), 6 deletions(-)
>  create mode 100644 Documentation/fb/api.txt
> 

> diff --git a/include/linux/fb.h b/include/linux/fb.h
> index 1d6836c..c6baf28 100644
> --- a/include/linux/fb.h
> +++ b/include/linux/fb.h
> @@ -69,6 +69,7 @@
>  #define FB_VISUAL_PSEUDOCOLOR		3	/* Pseudo color (like atari) */
>  #define FB_VISUAL_DIRECTCOLOR		4	/* Direct color */
>  #define FB_VISUAL_STATIC_PSEUDOCOLOR	5	/* Pseudo color readonly */
> +#define FB_VISUAL_FOURCC		6	/* Visual identified by a V4L2 FOURCC */
>  
>  #define FB_ACCEL_NONE		0	/* no hardware accelerator	*/
>  #define FB_ACCEL_ATARIBLITT	1	/* Atari Blitter		*/
> @@ -154,6 +155,8 @@
>  
>  #define FB_ACCEL_PUV3_UNIGFX	0xa0	/* PKUnity-v3 Unigfx		*/
>  
> +#define FB_CAP_FOURCC		1	/* Device supports FOURCC-based formats */
> +
>  struct fb_fix_screeninfo {
>  	char id[16];			/* identification string eg "TT Builtin" */
>  	unsigned long smem_start;	/* Start of frame buffer mem */
> @@ -171,7 +174,8 @@ struct fb_fix_screeninfo {
>  	__u32 mmio_len;			/* Length of Memory Mapped I/O  */
>  	__u32 accel;			/* Indicate to driver which	*/
>  					/*  specific chip/card we have	*/
> -	__u16 reserved[3];		/* Reserved for future compatibility */
> +	__u16 capabilities;		/* see FB_CAP_*			*/
> +	__u16 reserved[2];		/* Reserved for future compatibility */
>  };
>  
>  /* Interpretation of offset for color fields: All offsets are from the right,
> @@ -246,12 +250,23 @@ struct fb_var_screeninfo {
>  	__u32 yoffset;			/* resolution			*/
>  
>  	__u32 bits_per_pixel;		/* guess what			*/
> -	__u32 grayscale;		/* != 0 Graylevels instead of colors */
>  
> -	struct fb_bitfield red;		/* bitfield in fb mem if true color, */
> -	struct fb_bitfield green;	/* else only length is significant */
> -	struct fb_bitfield blue;
> -	struct fb_bitfield transp;	/* transparency			*/	
> +	union {
> +		struct {		/* Legacy format API		*/
> +			__u32 grayscale; /* != 0 Graylevels instead of colors */

You should adjust the comment as well, to avoid misleading crazy people ;)
Needs also be fixed in the documentation at some places.

> +			/* bitfields in fb mem if true color, else only */
> +			/* length is significant			*/
> +			struct fb_bitfield red;
> +			struct fb_bitfield green;
> +			struct fb_bitfield blue;
> +			struct fb_bitfield transp;	/* transparency	*/
> +		};
> +		struct {		/* FOURCC-based format API	*/
> +			__u32 fourcc;		/* FOURCC format	*/
> +			__u32 colorspace;

So we have again fields that are not always used. Okay, as we still have 11 left
that shouldn't be a big problem, I think.

> +			__u32 reserved[11];
> +		} format;

Ugh, if you want this union to have a name I suggest 'fourcc' and not 'format'
as the other struct contains format information as well and who knows, maybe in
10 or 20 years we'll have yet another format description that can do things none
of the existing can do.

> +	};
>  
>  	__u32 nonstd;			/* != 0 Non standard pixel format */
>  


Thanks,

Florian Tobias Schandinat

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration
@ 2011-08-26 17:07     ` Florian Tobias Schandinat
  0 siblings, 0 replies; 52+ messages in thread
From: Florian Tobias Schandinat @ 2011-08-26 17:07 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Laurent,

hope we're close to the final thing now. Just a few minor issues.

On 08/19/2011 09:37 AM, Laurent Pinchart wrote:
> This API will be used to support YUV frame buffer formats in a standard
> way.
> 
> Last but not least, create a much needed fbdev API documentation and
> document the format setting APIs.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  Documentation/fb/api.txt |  299 ++++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/fb.h       |   27 ++++-
>  2 files changed, 320 insertions(+), 6 deletions(-)
>  create mode 100644 Documentation/fb/api.txt
> 

> diff --git a/include/linux/fb.h b/include/linux/fb.h
> index 1d6836c..c6baf28 100644
> --- a/include/linux/fb.h
> +++ b/include/linux/fb.h
> @@ -69,6 +69,7 @@
>  #define FB_VISUAL_PSEUDOCOLOR		3	/* Pseudo color (like atari) */
>  #define FB_VISUAL_DIRECTCOLOR		4	/* Direct color */
>  #define FB_VISUAL_STATIC_PSEUDOCOLOR	5	/* Pseudo color readonly */
> +#define FB_VISUAL_FOURCC		6	/* Visual identified by a V4L2 FOURCC */
>  
>  #define FB_ACCEL_NONE		0	/* no hardware accelerator	*/
>  #define FB_ACCEL_ATARIBLITT	1	/* Atari Blitter		*/
> @@ -154,6 +155,8 @@
>  
>  #define FB_ACCEL_PUV3_UNIGFX	0xa0	/* PKUnity-v3 Unigfx		*/
>  
> +#define FB_CAP_FOURCC		1	/* Device supports FOURCC-based formats */
> +
>  struct fb_fix_screeninfo {
>  	char id[16];			/* identification string eg "TT Builtin" */
>  	unsigned long smem_start;	/* Start of frame buffer mem */
> @@ -171,7 +174,8 @@ struct fb_fix_screeninfo {
>  	__u32 mmio_len;			/* Length of Memory Mapped I/O  */
>  	__u32 accel;			/* Indicate to driver which	*/
>  					/*  specific chip/card we have	*/
> -	__u16 reserved[3];		/* Reserved for future compatibility */
> +	__u16 capabilities;		/* see FB_CAP_*			*/
> +	__u16 reserved[2];		/* Reserved for future compatibility */
>  };
>  
>  /* Interpretation of offset for color fields: All offsets are from the right,
> @@ -246,12 +250,23 @@ struct fb_var_screeninfo {
>  	__u32 yoffset;			/* resolution			*/
>  
>  	__u32 bits_per_pixel;		/* guess what			*/
> -	__u32 grayscale;		/* != 0 Graylevels instead of colors */
>  
> -	struct fb_bitfield red;		/* bitfield in fb mem if true color, */
> -	struct fb_bitfield green;	/* else only length is significant */
> -	struct fb_bitfield blue;
> -	struct fb_bitfield transp;	/* transparency			*/	
> +	union {
> +		struct {		/* Legacy format API		*/
> +			__u32 grayscale; /* != 0 Graylevels instead of colors */

You should adjust the comment as well, to avoid misleading crazy people ;)
Needs also be fixed in the documentation at some places.

> +			/* bitfields in fb mem if true color, else only */
> +			/* length is significant			*/
> +			struct fb_bitfield red;
> +			struct fb_bitfield green;
> +			struct fb_bitfield blue;
> +			struct fb_bitfield transp;	/* transparency	*/
> +		};
> +		struct {		/* FOURCC-based format API	*/
> +			__u32 fourcc;		/* FOURCC format	*/
> +			__u32 colorspace;

So we have again fields that are not always used. Okay, as we still have 11 left
that shouldn't be a big problem, I think.

> +			__u32 reserved[11];
> +		} format;

Ugh, if you want this union to have a name I suggest 'fourcc' and not 'format'
as the other struct contains format information as well and who knows, maybe in
10 or 20 years we'll have yet another format description that can do things none
of the existing can do.

> +	};
>  
>  	__u32 nonstd;			/* != 0 Non standard pixel format */
>  


Thanks,

Florian Tobias Schandinat

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 3/3] fbdev: sh_mobile_lcdc: Support FOURCC-based format API
  2011-08-19  9:37   ` Laurent Pinchart
@ 2011-08-26 17:24     ` Florian Tobias Schandinat
  -1 siblings, 0 replies; 52+ messages in thread
From: Florian Tobias Schandinat @ 2011-08-26 17:24 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Laurent,

On 08/19/2011 09:37 AM, Laurent Pinchart wrote:
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  arch/arm/mach-shmobile/board-ag5evm.c   |    2 +-
>  arch/arm/mach-shmobile/board-ap4evb.c   |    4 +-
>  arch/arm/mach-shmobile/board-mackerel.c |    4 +-
>  drivers/video/sh_mobile_lcdcfb.c        |  342 ++++++++++++++++++++-----------
>  include/video/sh_mobile_lcdc.h          |    4 +-
>  5 files changed, 230 insertions(+), 126 deletions(-)
> 
> diff --git a/arch/arm/mach-shmobile/board-ag5evm.c b/arch/arm/mach-shmobile/board-ag5evm.c
> index ce5c251..e6dabaa 100644
> --- a/arch/arm/mach-shmobile/board-ag5evm.c
> +++ b/arch/arm/mach-shmobile/board-ag5evm.c
> @@ -270,7 +270,7 @@ static struct sh_mobile_lcdc_info lcdc0_info = {
>  		.flags = LCDC_FLAGS_DWPOL,
>  		.lcd_size_cfg.width = 44,
>  		.lcd_size_cfg.height = 79,
> -		.bpp = 16,
> +		.fourcc = V4L2_PIX_FMT_RGB565,
>  		.lcd_cfg = lcdc0_modes,
>  		.num_cfg = ARRAY_SIZE(lcdc0_modes),
>  		.board_cfg = {
> diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c
> index 9e0856b..6f5db07 100644
> --- a/arch/arm/mach-shmobile/board-ap4evb.c
> +++ b/arch/arm/mach-shmobile/board-ap4evb.c
> @@ -489,7 +489,7 @@ static struct sh_mobile_lcdc_info lcdc_info = {
>  	.meram_dev = &meram_info,
>  	.ch[0] = {
>  		.chan = LCDC_CHAN_MAINLCD,
> -		.bpp = 16,
> +		.fourcc = V4L2_PIX_FMT_RGB565,
>  		.lcd_cfg = ap4evb_lcdc_modes,
>  		.num_cfg = ARRAY_SIZE(ap4evb_lcdc_modes),
>  		.meram_cfg = &lcd_meram_cfg,
> @@ -783,7 +783,7 @@ static struct sh_mobile_lcdc_info sh_mobile_lcdc1_info = {
>  	.meram_dev = &meram_info,
>  	.ch[0] = {
>  		.chan = LCDC_CHAN_MAINLCD,
> -		.bpp = 16,
> +		.fourcc = V4L2_PIX_FMT_RGB565,
>  		.interface_type = RGB24,
>  		.clock_divider = 1,
>  		.flags = LCDC_FLAGS_DWPOL,
> diff --git a/arch/arm/mach-shmobile/board-mackerel.c b/arch/arm/mach-shmobile/board-mackerel.c
> index 6e3c2df..6e36349 100644
> --- a/arch/arm/mach-shmobile/board-mackerel.c
> +++ b/arch/arm/mach-shmobile/board-mackerel.c
> @@ -387,7 +387,7 @@ static struct sh_mobile_lcdc_info lcdc_info = {
>  	.clock_source = LCDC_CLK_BUS,
>  	.ch[0] = {
>  		.chan = LCDC_CHAN_MAINLCD,
> -		.bpp = 16,
> +		.fourcc = V4L2_PIX_FMT_RGB565,
>  		.lcd_cfg = mackerel_lcdc_modes,
>  		.num_cfg = ARRAY_SIZE(mackerel_lcdc_modes),
>  		.interface_type		= RGB24,
> @@ -450,7 +450,7 @@ static struct sh_mobile_lcdc_info hdmi_lcdc_info = {
>  	.clock_source = LCDC_CLK_EXTERNAL,
>  	.ch[0] = {
>  		.chan = LCDC_CHAN_MAINLCD,
> -		.bpp = 16,
> +		.fourcc = V4L2_PIX_FMT_RGB565,
>  		.interface_type = RGB24,
>  		.clock_divider = 1,
>  		.flags = LCDC_FLAGS_DWPOL,
> diff --git a/drivers/video/sh_mobile_lcdcfb.c b/drivers/video/sh_mobile_lcdcfb.c
> index 97ab8ba..ea3f619 100644
> --- a/drivers/video/sh_mobile_lcdcfb.c
> +++ b/drivers/video/sh_mobile_lcdcfb.c
> @@ -17,6 +17,7 @@
>  #include <linux/platform_device.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/interrupt.h>
> +#include <linux/videodev2.h>
>  #include <linux/vmalloc.h>
>  #include <linux/ioctl.h>
>  #include <linux/slab.h>
> @@ -101,7 +102,7 @@ struct sh_mobile_lcdc_priv {
>  	struct sh_mobile_lcdc_chan ch[2];
>  	struct notifier_block notifier;
>  	int started;
> -	int forced_bpp; /* 2 channel LCDC must share bpp setting */
> +	int forced_fourcc; /* 2 channel LCDC must share fourcc setting */
>  	struct sh_mobile_meram_info *meram_dev;
>  };
>  
> @@ -214,6 +215,42 @@ struct sh_mobile_lcdc_sys_bus_ops sh_mobile_lcdc_sys_bus_ops = {
>  	lcdc_sys_read_data,
>  };
>  
> +static int sh_mobile_format_fourcc(const struct fb_var_screeninfo *var)
> +{
> +	if (var->format.fourcc > 1)
> +		return var->format.fourcc;
> +
> +	switch (var->bits_per_pixel) {
> +	case 16:
> +		return V4L2_PIX_FMT_RGB565;
> +	case 24:
> +		return V4L2_PIX_FMT_BGR24;
> +	case 32:
> +		return V4L2_PIX_FMT_BGR32;
> +	default:
> +		return 0;
> +	}
> +}
> +
> +static bool sh_mobile_format_yuv(const struct fb_var_screeninfo *var)
> +{
> +	if (var->format.fourcc <= 1)
> +		return false;
> +
> +	switch (var->format.fourcc) {
> +	case V4L2_PIX_FMT_NV12:
> +	case V4L2_PIX_FMT_NV21:
> +	case V4L2_PIX_FMT_NV16:
> +	case V4L2_PIX_FMT_NV61:
> +	case V4L2_PIX_FMT_NV24:
> +	case V4L2_PIX_FMT_NV42:
> +		return true;
> +
> +	default:
> +		return false;
> +	}
> +}
> +
>  static void sh_mobile_lcdc_clk_on(struct sh_mobile_lcdc_priv *priv)
>  {
>  	if (atomic_inc_and_test(&priv->hw_usecnt)) {
> @@ -434,7 +471,6 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
>  {
>  	struct sh_mobile_lcdc_chan *ch;
>  	unsigned long tmp;
> -	int bpp = 0;
>  	int k, m;
>  
>  	/* Enable LCDC channels. Read data from external memory, avoid using the
> @@ -453,9 +489,6 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
>  		if (!ch->enabled)
>  			continue;
>  
> -		if (!bpp)
> -			bpp = ch->info->var.bits_per_pixel;
> -
>  		/* Power supply */
>  		lcdc_write_chan(ch, LDPMR, 0);
>  
> @@ -486,31 +519,37 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
>  
>  		sh_mobile_lcdc_geometry(ch);
>  
> -		if (ch->info->var.nonstd) {
> -			tmp = (ch->info->var.nonstd << 16);
> -			switch (ch->info->var.bits_per_pixel) {
> -			case 12:
> -				tmp |= LDDFR_YF_420;
> -				break;
> -			case 16:
> -				tmp |= LDDFR_YF_422;
> -				break;
> -			case 24:
> -			default:
> -				tmp |= LDDFR_YF_444;
> -				break;
> -			}
> -		} else {
> -			switch (ch->info->var.bits_per_pixel) {
> -			case 16:
> -				tmp = LDDFR_PKF_RGB16;
> -				break;
> -			case 24:
> -				tmp = LDDFR_PKF_RGB24;
> +		switch (sh_mobile_format_fourcc(&ch->info->var)) {
> +		case V4L2_PIX_FMT_RGB565:
> +			tmp = LDDFR_PKF_RGB16;
> +			break;
> +		case V4L2_PIX_FMT_BGR24:
> +			tmp = LDDFR_PKF_RGB24;
> +			break;
> +		case V4L2_PIX_FMT_BGR32:
> +			tmp = LDDFR_PKF_ARGB32;
> +			break;
> +		case V4L2_PIX_FMT_NV12:
> +		case V4L2_PIX_FMT_NV21:
> +			tmp = LDDFR_CC | LDDFR_YF_420;
> +			break;
> +		case V4L2_PIX_FMT_NV16:
> +		case V4L2_PIX_FMT_NV61:
> +			tmp = LDDFR_CC | LDDFR_YF_422;
> +			break;
> +		case V4L2_PIX_FMT_NV24:
> +		case V4L2_PIX_FMT_NV42:
> +			tmp = LDDFR_CC | LDDFR_YF_444;
> +			break;
> +		}
> +
> +		if (sh_mobile_format_yuv(&ch->info->var)) {
> +			switch (ch->info->var.format.colorspace) {
> +			case V4L2_COLORSPACE_REC709:
> +				tmp |= LDDFR_CF1;
>  				break;
> -			case 32:
> -			default:
> -				tmp = LDDFR_PKF_ARGB32;
> +			case V4L2_COLORSPACE_JPEG:
> +				tmp |= LDDFR_CF0;
>  				break;
>  			}
>  		}
> @@ -518,7 +557,7 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
>  		lcdc_write_chan(ch, LDDFR, tmp);
>  		lcdc_write_chan(ch, LDMLSR, ch->pitch);
>  		lcdc_write_chan(ch, LDSA1R, ch->base_addr_y);
> -		if (ch->info->var.nonstd)
> +		if (sh_mobile_format_yuv(&ch->info->var))
>  			lcdc_write_chan(ch, LDSA2R, ch->base_addr_c);
>  
>  		/* When using deferred I/O mode, configure the LCDC for one-shot
> @@ -535,21 +574,23 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
>  	}
>  
>  	/* Word and long word swap. */
> -	if  (priv->ch[0].info->var.nonstd)
> +	switch (sh_mobile_format_fourcc(&priv->ch[0].info->var)) {
> +	case V4L2_PIX_FMT_RGB565:
> +	case V4L2_PIX_FMT_NV21:
> +	case V4L2_PIX_FMT_NV61:
> +	case V4L2_PIX_FMT_NV42:
> +		tmp = LDDDSR_LS | LDDDSR_WS;
> +		break;
> +	case V4L2_PIX_FMT_BGR24:
> +	case V4L2_PIX_FMT_NV12:
> +	case V4L2_PIX_FMT_NV16:
> +	case V4L2_PIX_FMT_NV24:
>  		tmp = LDDDSR_LS | LDDDSR_WS | LDDDSR_BS;
> -	else {
> -		switch (bpp) {
> -		case 16:
> -			tmp = LDDDSR_LS | LDDDSR_WS;
> -			break;
> -		case 24:
> -			tmp = LDDDSR_LS | LDDDSR_WS | LDDDSR_BS;
> -			break;
> -		case 32:
> -		default:
> -			tmp = LDDDSR_LS;
> -			break;
> -		}
> +		break;
> +	case V4L2_PIX_FMT_BGR32:
> +	default:
> +		tmp = LDDDSR_LS;
> +		break;
>  	}
>  	lcdc_write(priv, _LDDDSR, tmp);
>  
> @@ -621,12 +662,24 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
>  			ch->meram_enabled = 0;
>  		}
>  
> -		if (!ch->info->var.nonstd)
> -			pixelformat = SH_MOBILE_MERAM_PF_RGB;
> -		else if (ch->info->var.bits_per_pixel == 24)
> -			pixelformat = SH_MOBILE_MERAM_PF_NV24;
> -		else
> +		switch (sh_mobile_format_fourcc(&ch->info->var)) {
> +		case V4L2_PIX_FMT_NV12:
> +		case V4L2_PIX_FMT_NV21:
> +		case V4L2_PIX_FMT_NV16:
> +		case V4L2_PIX_FMT_NV61:
>  			pixelformat = SH_MOBILE_MERAM_PF_NV;
> +			break;
> +		case V4L2_PIX_FMT_NV24:
> +		case V4L2_PIX_FMT_NV42:
> +			pixelformat = SH_MOBILE_MERAM_PF_NV24;
> +			break;
> +		case V4L2_PIX_FMT_RGB565:
> +		case V4L2_PIX_FMT_BGR24:
> +		case V4L2_PIX_FMT_BGR32:
> +		default:
> +			pixelformat = SH_MOBILE_MERAM_PF_RGB;
> +			break;
> +		}
>  
>  		ret = mdev->ops->meram_register(mdev, cfg, ch->pitch,
>  					ch->info->var.yres, pixelformat,
> @@ -844,6 +897,7 @@ static struct fb_fix_screeninfo sh_mobile_lcdc_fix  = {
>  	.xpanstep =	0,
>  	.ypanstep =	1,
>  	.ywrapstep =	0,
> +	.capabilities =	FB_CAP_FOURCC,
>  };
>  
>  static void sh_mobile_lcdc_fillrect(struct fb_info *info,
> @@ -876,8 +930,9 @@ static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var,
>  	unsigned long new_pan_offset;
>  	unsigned long base_addr_y, base_addr_c;
>  	unsigned long c_offset;
> +	bool yuv = sh_mobile_format_yuv(&info->var);
>  
> -	if (!info->var.nonstd)
> +	if (!yuv)
>  		new_pan_offset = var->yoffset * info->fix.line_length
>  			       + var->xoffset * (info->var.bits_per_pixel / 8);
>  	else
> @@ -891,7 +946,7 @@ static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var,
>  
>  	/* Set the source address for the next refresh */
>  	base_addr_y = ch->dma_handle + new_pan_offset;
> -	if (info->var.nonstd) {
> +	if (yuv) {
>  		/* Set y offset */
>  		c_offset = var->yoffset * info->fix.line_length
>  			 * (info->var.bits_per_pixel - 8) / 8;
> @@ -899,7 +954,7 @@ static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var,
>  			    + info->var.xres * info->var.yres_virtual
>  			    + c_offset;
>  		/* Set x offset */
> -		if (info->var.bits_per_pixel == 24)
> +		if (sh_mobile_format_fourcc(&info->var) == V4L2_PIX_FMT_NV24)
>  			base_addr_c += 2 * var->xoffset;
>  		else
>  			base_addr_c += var->xoffset;
> @@ -923,7 +978,7 @@ static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var,
>  	ch->base_addr_c = base_addr_c;
>  
>  	lcdc_write_chan_mirror(ch, LDSA1R, base_addr_y);
> -	if (info->var.nonstd)
> +	if (yuv)
>  		lcdc_write_chan_mirror(ch, LDSA2R, base_addr_c);
>  
>  	if (lcdc_chan_is_sublcd(ch))
> @@ -1099,51 +1154,78 @@ static int sh_mobile_check_var(struct fb_var_screeninfo *var, struct fb_info *in
>  	if (var->yres_virtual < var->yres)
>  		var->yres_virtual = var->yres;
>  
> -	if (var->bits_per_pixel <= 16) {		/* RGB 565 */
> -		var->bits_per_pixel = 16;
> -		var->red.offset = 11;
> -		var->red.length = 5;
> -		var->green.offset = 5;
> -		var->green.length = 6;
> -		var->blue.offset = 0;
> -		var->blue.length = 5;
> -		var->transp.offset = 0;
> -		var->transp.length = 0;
> -	} else if (var->bits_per_pixel <= 24) {		/* RGB 888 */
> -		var->bits_per_pixel = 24;
> -		var->red.offset = 16;
> -		var->red.length = 8;
> -		var->green.offset = 8;
> -		var->green.length = 8;
> -		var->blue.offset = 0;
> -		var->blue.length = 8;
> -		var->transp.offset = 0;
> -		var->transp.length = 0;
> -	} else if (var->bits_per_pixel <= 32) {		/* RGBA 888 */
> -		var->bits_per_pixel = 32;
> -		var->red.offset = 16;
> -		var->red.length = 8;
> -		var->green.offset = 8;
> -		var->green.length = 8;
> -		var->blue.offset = 0;
> -		var->blue.length = 8;
> -		var->transp.offset = 24;
> -		var->transp.length = 8;
> -	} else
> -		return -EINVAL;
> +	if (var->format.fourcc > 1) {
> +		switch (var->format.fourcc) {
> +		case V4L2_PIX_FMT_NV12:
> +		case V4L2_PIX_FMT_NV21:
> +			var->bits_per_pixel = 12;
> +			break;
> +		case V4L2_PIX_FMT_RGB565:
> +		case V4L2_PIX_FMT_NV16:
> +		case V4L2_PIX_FMT_NV61:
> +			var->bits_per_pixel = 16;
> +			break;
> +		case V4L2_PIX_FMT_BGR24:
> +		case V4L2_PIX_FMT_NV24:
> +		case V4L2_PIX_FMT_NV42:
> +			var->bits_per_pixel = 24;
> +			break;
> +		case V4L2_PIX_FMT_BGR32:
> +			var->bits_per_pixel = 32;
> +			break;
> +		default:
> +			return -EINVAL;
> +		}
> +
> +		memset(var->format.reserved, 0, sizeof(var->format.reserved));

If we decide to use another of the reserved area this won't have the desired
behavior as the behavior of this driver will change even if it does not support
the new field. Probably the best thing is to get the desired behavior is zeroing
the whole struct and setting the supported fields to the actual values.
You should check and adjust colorspace here as well.

> +	} else {
> +		if (var->bits_per_pixel <= 16) {		/* RGB 565 */
> +			var->bits_per_pixel = 16;
> +			var->red.offset = 11;
> +			var->red.length = 5;
> +			var->green.offset = 5;
> +			var->green.length = 6;
> +			var->blue.offset = 0;
> +			var->blue.length = 5;
> +			var->transp.offset = 0;
> +			var->transp.length = 0;
> +		} else if (var->bits_per_pixel <= 24) {		/* RGB 888 */
> +			var->bits_per_pixel = 24;
> +			var->red.offset = 16;
> +			var->red.length = 8;
> +			var->green.offset = 8;
> +			var->green.length = 8;
> +			var->blue.offset = 0;
> +			var->blue.length = 8;
> +			var->transp.offset = 0;
> +			var->transp.length = 0;
> +		} else if (var->bits_per_pixel <= 32) {		/* RGBA 888 */
> +			var->bits_per_pixel = 32;
> +			var->red.offset = 16;
> +			var->red.length = 8;
> +			var->green.offset = 8;
> +			var->green.length = 8;
> +			var->blue.offset = 0;
> +			var->blue.length = 8;
> +			var->transp.offset = 24;
> +			var->transp.length = 8;
> +		} else
> +			return -EINVAL;
>  
> -	var->red.msb_right = 0;
> -	var->green.msb_right = 0;
> -	var->blue.msb_right = 0;
> -	var->transp.msb_right = 0;
> +		var->red.msb_right = 0;
> +		var->green.msb_right = 0;
> +		var->blue.msb_right = 0;
> +		var->transp.msb_right = 0;
> +	}
>  
>  	/* Make sure we don't exceed our allocated memory. */
>  	if (var->xres_virtual * var->yres_virtual * var->bits_per_pixel / 8 >
>  	    info->fix.smem_len)
>  		return -EINVAL;
>  
> -	/* only accept the forced_bpp for dual channel configurations */
> -	if (p->forced_bpp && p->forced_bpp != var->bits_per_pixel)
> +	/* only accept the forced_fourcc for dual channel configurations */
> +	if (p->forced_fourcc &&
> +	    p->forced_fourcc != sh_mobile_format_fourcc(var))
>  		return -EINVAL;
>  
>  	return 0;
> @@ -1157,7 +1239,7 @@ static int sh_mobile_set_par(struct fb_info *info)
>  
>  	sh_mobile_lcdc_stop(ch->lcdc);
>  
> -	if (info->var.nonstd)
> +	if (sh_mobile_format_yuv(&info->var))
>  		info->fix.line_length = info->var.xres;
>  	else
>  		info->fix.line_length = info->var.xres
> @@ -1169,6 +1251,11 @@ static int sh_mobile_set_par(struct fb_info *info)
>  		info->fix.line_length = line_length;
>  	}
>  
> +	if (info->var.format.fourcc > 1)
> +		info->fix.visual = FB_VISUAL_FOURCC;
> +	else
> +		info->fix.visual = FB_VISUAL_TRUECOLOR;
> +
>  	return ret;
>  }
>  
> @@ -1463,9 +1550,9 @@ static int __devinit sh_mobile_lcdc_channel_init(struct sh_mobile_lcdc_chan *ch,
>  	for (i = 0, mode = cfg->lcd_cfg; i < cfg->num_cfg; i++, mode++) {
>  		unsigned int size = mode->yres * mode->xres;
>  
> -		/* NV12 buffers must have even number of lines */
> -		if ((cfg->nonstd) && cfg->bpp == 12 &&
> -				(mode->yres & 0x1)) {
> +		/* NV12/NV21 buffers must have even number of lines */
> +		if ((cfg->fourcc == V4L2_PIX_FMT_NV12 ||
> +		     cfg->fourcc == V4L2_PIX_FMT_NV21) && (mode->yres & 0x1)) {
>  			dev_err(dev, "yres must be multiple of 2 for YCbCr420 "
>  				"mode.\n");
>  			return -EINVAL;
> @@ -1483,14 +1570,6 @@ static int __devinit sh_mobile_lcdc_channel_init(struct sh_mobile_lcdc_chan *ch,
>  		dev_dbg(dev, "Found largest videomode %ux%u\n",
>  			max_mode->xres, max_mode->yres);
>  
> -	/* Initialize fixed screen information. Restrict pan to 2 lines steps
> -	 * for NV12.
> -	 */
> -	info->fix = sh_mobile_lcdc_fix;
> -	info->fix.smem_len = max_size * 2 * cfg->bpp / 8;
> -	if (cfg->nonstd && cfg->bpp == 12)
> -		info->fix.ypanstep = 2;
> -
>  	/* Create the mode list. */
>  	if (cfg->lcd_cfg == NULL) {
>  		mode = &default_720p;
> @@ -1508,19 +1587,38 @@ static int __devinit sh_mobile_lcdc_channel_init(struct sh_mobile_lcdc_chan *ch,
>  	 */
>  	var = &info->var;
>  	fb_videomode_to_var(var, mode);
> -	var->bits_per_pixel = cfg->bpp;
>  	var->width = cfg->lcd_size_cfg.width;
>  	var->height = cfg->lcd_size_cfg.height;
>  	var->yres_virtual = var->yres * 2;
>  	var->activate = FB_ACTIVATE_NOW;
>  
> +	switch (cfg->fourcc) {
> +	case V4L2_PIX_FMT_RGB565:
> +		var->bits_per_pixel = 16;
> +		break;
> +	case V4L2_PIX_FMT_BGR24:
> +		var->bits_per_pixel = 24;
> +		break;
> +	case V4L2_PIX_FMT_BGR32:
> +		var->bits_per_pixel = 32;
> +		break;
> +	default:
> +		var->format.fourcc = cfg->fourcc;
> +		break;
> +	}
> +
> +	/* Make sure the memory size check won't fail. smem_len is initialized
> +	 * later based on var.
> +	 */
> +	info->fix.smem_len = UINT_MAX;
>  	ret = sh_mobile_check_var(var, info);
>  	if (ret)
>  		return ret;
>  
> +	max_size *= var->bits_per_pixel / 8 * 2;
> +
>  	/* Allocate frame buffer memory and color map. */
> -	buf = dma_alloc_coherent(dev, info->fix.smem_len, &ch->dma_handle,
> -				 GFP_KERNEL);
> +	buf = dma_alloc_coherent(dev, max_size, &ch->dma_handle, GFP_KERNEL);
>  	if (!buf) {
>  		dev_err(dev, "unable to allocate buffer\n");
>  		return -ENOMEM;
> @@ -1529,16 +1627,25 @@ static int __devinit sh_mobile_lcdc_channel_init(struct sh_mobile_lcdc_chan *ch,
>  	ret = fb_alloc_cmap(&info->cmap, PALETTE_NR, 0);
>  	if (ret < 0) {
>  		dev_err(dev, "unable to allocate cmap\n");
> -		dma_free_coherent(dev, info->fix.smem_len,
> -				  buf, ch->dma_handle);
> +		dma_free_coherent(dev, max_size, buf, ch->dma_handle);
>  		return ret;
>  	}
>  
> +	/* Initialize fixed screen information. Restrict pan to 2 lines steps
> +	 * for NV12 and NV21.
> +	 */
> +	info->fix = sh_mobile_lcdc_fix;
>  	info->fix.smem_start = ch->dma_handle;
> -	if (var->nonstd)
> +	info->fix.smem_len = max_size * var->bits_per_pixel / 8 * 2;
> +	if (cfg->fourcc == V4L2_PIX_FMT_NV12 ||
> +	    cfg->fourcc == V4L2_PIX_FMT_NV21)
> +		info->fix.ypanstep = 2;
> +
> +	if (sh_mobile_format_yuv(var))
>  		info->fix.line_length = var->xres;
>  	else
> -		info->fix.line_length = var->xres * (cfg->bpp / 8);
> +		info->fix.line_length = var->xres * var->bits_per_pixel
> +				      / 8;
>  
>  	info->screen_base = buf;
>  	info->device = dev;
> @@ -1625,9 +1732,9 @@ static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev)
>  		goto err1;
>  	}
>  
> -	/* for dual channel LCDC (MAIN + SUB) force shared bpp setting */
> +	/* for dual channel LCDC (MAIN + SUB) force shared format setting */
>  	if (num_channels == 2)
> -		priv->forced_bpp = pdata->ch[0].bpp;
> +		priv->forced_fourcc = pdata->ch[0].fourcc;
>  
>  	priv->base = ioremap_nocache(res->start, resource_size(res));
>  	if (!priv->base)
> @@ -1674,13 +1781,10 @@ static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev)
>  		if (error < 0)
>  			goto err1;
>  
> -		dev_info(info->dev,
> -			 "registered %s/%s as %dx%d %dbpp.\n",
> -			 pdev->name,
> -			 (ch->cfg.chan == LCDC_CHAN_MAINLCD) ?
> -			 "mainlcd" : "sublcd",
> -			 info->var.xres, info->var.yres,
> -			 ch->cfg.bpp);
> +		dev_info(info->dev, "registered %s/%s as %dx%d %dbpp.\n",
> +			 pdev->name, (ch->cfg.chan == LCDC_CHAN_MAINLCD) ?
> +			 "mainlcd" : "sublcd", info->var.xres, info->var.yres,
> +			 info->var.bits_per_pixel);
>  
>  		/* deferred io mode: disable clock to save power */
>  		if (info->fbdefio || info->state == FBINFO_STATE_SUSPENDED)
> diff --git a/include/video/sh_mobile_lcdc.h b/include/video/sh_mobile_lcdc.h
> index 8101b72..fe30b75 100644
> --- a/include/video/sh_mobile_lcdc.h
> +++ b/include/video/sh_mobile_lcdc.h
> @@ -174,7 +174,8 @@ struct sh_mobile_lcdc_bl_info {
>  
>  struct sh_mobile_lcdc_chan_cfg {
>  	int chan;
> -	int bpp;
> +	int fourcc;
> +	int colorspace;
>  	int interface_type; /* selects RGBn or SYSn I/F, see above */
>  	int clock_divider;
>  	unsigned long flags; /* LCDC_FLAGS_... */
> @@ -184,7 +185,6 @@ struct sh_mobile_lcdc_chan_cfg {
>  	struct sh_mobile_lcdc_board_cfg board_cfg;
>  	struct sh_mobile_lcdc_bl_info bl_info;
>  	struct sh_mobile_lcdc_sys_bus_cfg sys_bus_cfg; /* only for SYSn I/F */
> -	int nonstd;
>  	struct sh_mobile_meram_cfg *meram_cfg;
>  };
>  


Thanks,

Florian Tobias Schandinat

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 3/3] fbdev: sh_mobile_lcdc: Support FOURCC-based
@ 2011-08-26 17:24     ` Florian Tobias Schandinat
  0 siblings, 0 replies; 52+ messages in thread
From: Florian Tobias Schandinat @ 2011-08-26 17:24 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Laurent,

On 08/19/2011 09:37 AM, Laurent Pinchart wrote:
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  arch/arm/mach-shmobile/board-ag5evm.c   |    2 +-
>  arch/arm/mach-shmobile/board-ap4evb.c   |    4 +-
>  arch/arm/mach-shmobile/board-mackerel.c |    4 +-
>  drivers/video/sh_mobile_lcdcfb.c        |  342 ++++++++++++++++++++-----------
>  include/video/sh_mobile_lcdc.h          |    4 +-
>  5 files changed, 230 insertions(+), 126 deletions(-)
> 
> diff --git a/arch/arm/mach-shmobile/board-ag5evm.c b/arch/arm/mach-shmobile/board-ag5evm.c
> index ce5c251..e6dabaa 100644
> --- a/arch/arm/mach-shmobile/board-ag5evm.c
> +++ b/arch/arm/mach-shmobile/board-ag5evm.c
> @@ -270,7 +270,7 @@ static struct sh_mobile_lcdc_info lcdc0_info = {
>  		.flags = LCDC_FLAGS_DWPOL,
>  		.lcd_size_cfg.width = 44,
>  		.lcd_size_cfg.height = 79,
> -		.bpp = 16,
> +		.fourcc = V4L2_PIX_FMT_RGB565,
>  		.lcd_cfg = lcdc0_modes,
>  		.num_cfg = ARRAY_SIZE(lcdc0_modes),
>  		.board_cfg = {
> diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c
> index 9e0856b..6f5db07 100644
> --- a/arch/arm/mach-shmobile/board-ap4evb.c
> +++ b/arch/arm/mach-shmobile/board-ap4evb.c
> @@ -489,7 +489,7 @@ static struct sh_mobile_lcdc_info lcdc_info = {
>  	.meram_dev = &meram_info,
>  	.ch[0] = {
>  		.chan = LCDC_CHAN_MAINLCD,
> -		.bpp = 16,
> +		.fourcc = V4L2_PIX_FMT_RGB565,
>  		.lcd_cfg = ap4evb_lcdc_modes,
>  		.num_cfg = ARRAY_SIZE(ap4evb_lcdc_modes),
>  		.meram_cfg = &lcd_meram_cfg,
> @@ -783,7 +783,7 @@ static struct sh_mobile_lcdc_info sh_mobile_lcdc1_info = {
>  	.meram_dev = &meram_info,
>  	.ch[0] = {
>  		.chan = LCDC_CHAN_MAINLCD,
> -		.bpp = 16,
> +		.fourcc = V4L2_PIX_FMT_RGB565,
>  		.interface_type = RGB24,
>  		.clock_divider = 1,
>  		.flags = LCDC_FLAGS_DWPOL,
> diff --git a/arch/arm/mach-shmobile/board-mackerel.c b/arch/arm/mach-shmobile/board-mackerel.c
> index 6e3c2df..6e36349 100644
> --- a/arch/arm/mach-shmobile/board-mackerel.c
> +++ b/arch/arm/mach-shmobile/board-mackerel.c
> @@ -387,7 +387,7 @@ static struct sh_mobile_lcdc_info lcdc_info = {
>  	.clock_source = LCDC_CLK_BUS,
>  	.ch[0] = {
>  		.chan = LCDC_CHAN_MAINLCD,
> -		.bpp = 16,
> +		.fourcc = V4L2_PIX_FMT_RGB565,
>  		.lcd_cfg = mackerel_lcdc_modes,
>  		.num_cfg = ARRAY_SIZE(mackerel_lcdc_modes),
>  		.interface_type		= RGB24,
> @@ -450,7 +450,7 @@ static struct sh_mobile_lcdc_info hdmi_lcdc_info = {
>  	.clock_source = LCDC_CLK_EXTERNAL,
>  	.ch[0] = {
>  		.chan = LCDC_CHAN_MAINLCD,
> -		.bpp = 16,
> +		.fourcc = V4L2_PIX_FMT_RGB565,
>  		.interface_type = RGB24,
>  		.clock_divider = 1,
>  		.flags = LCDC_FLAGS_DWPOL,
> diff --git a/drivers/video/sh_mobile_lcdcfb.c b/drivers/video/sh_mobile_lcdcfb.c
> index 97ab8ba..ea3f619 100644
> --- a/drivers/video/sh_mobile_lcdcfb.c
> +++ b/drivers/video/sh_mobile_lcdcfb.c
> @@ -17,6 +17,7 @@
>  #include <linux/platform_device.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/interrupt.h>
> +#include <linux/videodev2.h>
>  #include <linux/vmalloc.h>
>  #include <linux/ioctl.h>
>  #include <linux/slab.h>
> @@ -101,7 +102,7 @@ struct sh_mobile_lcdc_priv {
>  	struct sh_mobile_lcdc_chan ch[2];
>  	struct notifier_block notifier;
>  	int started;
> -	int forced_bpp; /* 2 channel LCDC must share bpp setting */
> +	int forced_fourcc; /* 2 channel LCDC must share fourcc setting */
>  	struct sh_mobile_meram_info *meram_dev;
>  };
>  
> @@ -214,6 +215,42 @@ struct sh_mobile_lcdc_sys_bus_ops sh_mobile_lcdc_sys_bus_ops = {
>  	lcdc_sys_read_data,
>  };
>  
> +static int sh_mobile_format_fourcc(const struct fb_var_screeninfo *var)
> +{
> +	if (var->format.fourcc > 1)
> +		return var->format.fourcc;
> +
> +	switch (var->bits_per_pixel) {
> +	case 16:
> +		return V4L2_PIX_FMT_RGB565;
> +	case 24:
> +		return V4L2_PIX_FMT_BGR24;
> +	case 32:
> +		return V4L2_PIX_FMT_BGR32;
> +	default:
> +		return 0;
> +	}
> +}
> +
> +static bool sh_mobile_format_yuv(const struct fb_var_screeninfo *var)
> +{
> +	if (var->format.fourcc <= 1)
> +		return false;
> +
> +	switch (var->format.fourcc) {
> +	case V4L2_PIX_FMT_NV12:
> +	case V4L2_PIX_FMT_NV21:
> +	case V4L2_PIX_FMT_NV16:
> +	case V4L2_PIX_FMT_NV61:
> +	case V4L2_PIX_FMT_NV24:
> +	case V4L2_PIX_FMT_NV42:
> +		return true;
> +
> +	default:
> +		return false;
> +	}
> +}
> +
>  static void sh_mobile_lcdc_clk_on(struct sh_mobile_lcdc_priv *priv)
>  {
>  	if (atomic_inc_and_test(&priv->hw_usecnt)) {
> @@ -434,7 +471,6 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
>  {
>  	struct sh_mobile_lcdc_chan *ch;
>  	unsigned long tmp;
> -	int bpp = 0;
>  	int k, m;
>  
>  	/* Enable LCDC channels. Read data from external memory, avoid using the
> @@ -453,9 +489,6 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
>  		if (!ch->enabled)
>  			continue;
>  
> -		if (!bpp)
> -			bpp = ch->info->var.bits_per_pixel;
> -
>  		/* Power supply */
>  		lcdc_write_chan(ch, LDPMR, 0);
>  
> @@ -486,31 +519,37 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
>  
>  		sh_mobile_lcdc_geometry(ch);
>  
> -		if (ch->info->var.nonstd) {
> -			tmp = (ch->info->var.nonstd << 16);
> -			switch (ch->info->var.bits_per_pixel) {
> -			case 12:
> -				tmp |= LDDFR_YF_420;
> -				break;
> -			case 16:
> -				tmp |= LDDFR_YF_422;
> -				break;
> -			case 24:
> -			default:
> -				tmp |= LDDFR_YF_444;
> -				break;
> -			}
> -		} else {
> -			switch (ch->info->var.bits_per_pixel) {
> -			case 16:
> -				tmp = LDDFR_PKF_RGB16;
> -				break;
> -			case 24:
> -				tmp = LDDFR_PKF_RGB24;
> +		switch (sh_mobile_format_fourcc(&ch->info->var)) {
> +		case V4L2_PIX_FMT_RGB565:
> +			tmp = LDDFR_PKF_RGB16;
> +			break;
> +		case V4L2_PIX_FMT_BGR24:
> +			tmp = LDDFR_PKF_RGB24;
> +			break;
> +		case V4L2_PIX_FMT_BGR32:
> +			tmp = LDDFR_PKF_ARGB32;
> +			break;
> +		case V4L2_PIX_FMT_NV12:
> +		case V4L2_PIX_FMT_NV21:
> +			tmp = LDDFR_CC | LDDFR_YF_420;
> +			break;
> +		case V4L2_PIX_FMT_NV16:
> +		case V4L2_PIX_FMT_NV61:
> +			tmp = LDDFR_CC | LDDFR_YF_422;
> +			break;
> +		case V4L2_PIX_FMT_NV24:
> +		case V4L2_PIX_FMT_NV42:
> +			tmp = LDDFR_CC | LDDFR_YF_444;
> +			break;
> +		}
> +
> +		if (sh_mobile_format_yuv(&ch->info->var)) {
> +			switch (ch->info->var.format.colorspace) {
> +			case V4L2_COLORSPACE_REC709:
> +				tmp |= LDDFR_CF1;
>  				break;
> -			case 32:
> -			default:
> -				tmp = LDDFR_PKF_ARGB32;
> +			case V4L2_COLORSPACE_JPEG:
> +				tmp |= LDDFR_CF0;
>  				break;
>  			}
>  		}
> @@ -518,7 +557,7 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
>  		lcdc_write_chan(ch, LDDFR, tmp);
>  		lcdc_write_chan(ch, LDMLSR, ch->pitch);
>  		lcdc_write_chan(ch, LDSA1R, ch->base_addr_y);
> -		if (ch->info->var.nonstd)
> +		if (sh_mobile_format_yuv(&ch->info->var))
>  			lcdc_write_chan(ch, LDSA2R, ch->base_addr_c);
>  
>  		/* When using deferred I/O mode, configure the LCDC for one-shot
> @@ -535,21 +574,23 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
>  	}
>  
>  	/* Word and long word swap. */
> -	if  (priv->ch[0].info->var.nonstd)
> +	switch (sh_mobile_format_fourcc(&priv->ch[0].info->var)) {
> +	case V4L2_PIX_FMT_RGB565:
> +	case V4L2_PIX_FMT_NV21:
> +	case V4L2_PIX_FMT_NV61:
> +	case V4L2_PIX_FMT_NV42:
> +		tmp = LDDDSR_LS | LDDDSR_WS;
> +		break;
> +	case V4L2_PIX_FMT_BGR24:
> +	case V4L2_PIX_FMT_NV12:
> +	case V4L2_PIX_FMT_NV16:
> +	case V4L2_PIX_FMT_NV24:
>  		tmp = LDDDSR_LS | LDDDSR_WS | LDDDSR_BS;
> -	else {
> -		switch (bpp) {
> -		case 16:
> -			tmp = LDDDSR_LS | LDDDSR_WS;
> -			break;
> -		case 24:
> -			tmp = LDDDSR_LS | LDDDSR_WS | LDDDSR_BS;
> -			break;
> -		case 32:
> -		default:
> -			tmp = LDDDSR_LS;
> -			break;
> -		}
> +		break;
> +	case V4L2_PIX_FMT_BGR32:
> +	default:
> +		tmp = LDDDSR_LS;
> +		break;
>  	}
>  	lcdc_write(priv, _LDDDSR, tmp);
>  
> @@ -621,12 +662,24 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
>  			ch->meram_enabled = 0;
>  		}
>  
> -		if (!ch->info->var.nonstd)
> -			pixelformat = SH_MOBILE_MERAM_PF_RGB;
> -		else if (ch->info->var.bits_per_pixel = 24)
> -			pixelformat = SH_MOBILE_MERAM_PF_NV24;
> -		else
> +		switch (sh_mobile_format_fourcc(&ch->info->var)) {
> +		case V4L2_PIX_FMT_NV12:
> +		case V4L2_PIX_FMT_NV21:
> +		case V4L2_PIX_FMT_NV16:
> +		case V4L2_PIX_FMT_NV61:
>  			pixelformat = SH_MOBILE_MERAM_PF_NV;
> +			break;
> +		case V4L2_PIX_FMT_NV24:
> +		case V4L2_PIX_FMT_NV42:
> +			pixelformat = SH_MOBILE_MERAM_PF_NV24;
> +			break;
> +		case V4L2_PIX_FMT_RGB565:
> +		case V4L2_PIX_FMT_BGR24:
> +		case V4L2_PIX_FMT_BGR32:
> +		default:
> +			pixelformat = SH_MOBILE_MERAM_PF_RGB;
> +			break;
> +		}
>  
>  		ret = mdev->ops->meram_register(mdev, cfg, ch->pitch,
>  					ch->info->var.yres, pixelformat,
> @@ -844,6 +897,7 @@ static struct fb_fix_screeninfo sh_mobile_lcdc_fix  = {
>  	.xpanstep =	0,
>  	.ypanstep =	1,
>  	.ywrapstep =	0,
> +	.capabilities =	FB_CAP_FOURCC,
>  };
>  
>  static void sh_mobile_lcdc_fillrect(struct fb_info *info,
> @@ -876,8 +930,9 @@ static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var,
>  	unsigned long new_pan_offset;
>  	unsigned long base_addr_y, base_addr_c;
>  	unsigned long c_offset;
> +	bool yuv = sh_mobile_format_yuv(&info->var);
>  
> -	if (!info->var.nonstd)
> +	if (!yuv)
>  		new_pan_offset = var->yoffset * info->fix.line_length
>  			       + var->xoffset * (info->var.bits_per_pixel / 8);
>  	else
> @@ -891,7 +946,7 @@ static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var,
>  
>  	/* Set the source address for the next refresh */
>  	base_addr_y = ch->dma_handle + new_pan_offset;
> -	if (info->var.nonstd) {
> +	if (yuv) {
>  		/* Set y offset */
>  		c_offset = var->yoffset * info->fix.line_length
>  			 * (info->var.bits_per_pixel - 8) / 8;
> @@ -899,7 +954,7 @@ static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var,
>  			    + info->var.xres * info->var.yres_virtual
>  			    + c_offset;
>  		/* Set x offset */
> -		if (info->var.bits_per_pixel = 24)
> +		if (sh_mobile_format_fourcc(&info->var) = V4L2_PIX_FMT_NV24)
>  			base_addr_c += 2 * var->xoffset;
>  		else
>  			base_addr_c += var->xoffset;
> @@ -923,7 +978,7 @@ static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var,
>  	ch->base_addr_c = base_addr_c;
>  
>  	lcdc_write_chan_mirror(ch, LDSA1R, base_addr_y);
> -	if (info->var.nonstd)
> +	if (yuv)
>  		lcdc_write_chan_mirror(ch, LDSA2R, base_addr_c);
>  
>  	if (lcdc_chan_is_sublcd(ch))
> @@ -1099,51 +1154,78 @@ static int sh_mobile_check_var(struct fb_var_screeninfo *var, struct fb_info *in
>  	if (var->yres_virtual < var->yres)
>  		var->yres_virtual = var->yres;
>  
> -	if (var->bits_per_pixel <= 16) {		/* RGB 565 */
> -		var->bits_per_pixel = 16;
> -		var->red.offset = 11;
> -		var->red.length = 5;
> -		var->green.offset = 5;
> -		var->green.length = 6;
> -		var->blue.offset = 0;
> -		var->blue.length = 5;
> -		var->transp.offset = 0;
> -		var->transp.length = 0;
> -	} else if (var->bits_per_pixel <= 24) {		/* RGB 888 */
> -		var->bits_per_pixel = 24;
> -		var->red.offset = 16;
> -		var->red.length = 8;
> -		var->green.offset = 8;
> -		var->green.length = 8;
> -		var->blue.offset = 0;
> -		var->blue.length = 8;
> -		var->transp.offset = 0;
> -		var->transp.length = 0;
> -	} else if (var->bits_per_pixel <= 32) {		/* RGBA 888 */
> -		var->bits_per_pixel = 32;
> -		var->red.offset = 16;
> -		var->red.length = 8;
> -		var->green.offset = 8;
> -		var->green.length = 8;
> -		var->blue.offset = 0;
> -		var->blue.length = 8;
> -		var->transp.offset = 24;
> -		var->transp.length = 8;
> -	} else
> -		return -EINVAL;
> +	if (var->format.fourcc > 1) {
> +		switch (var->format.fourcc) {
> +		case V4L2_PIX_FMT_NV12:
> +		case V4L2_PIX_FMT_NV21:
> +			var->bits_per_pixel = 12;
> +			break;
> +		case V4L2_PIX_FMT_RGB565:
> +		case V4L2_PIX_FMT_NV16:
> +		case V4L2_PIX_FMT_NV61:
> +			var->bits_per_pixel = 16;
> +			break;
> +		case V4L2_PIX_FMT_BGR24:
> +		case V4L2_PIX_FMT_NV24:
> +		case V4L2_PIX_FMT_NV42:
> +			var->bits_per_pixel = 24;
> +			break;
> +		case V4L2_PIX_FMT_BGR32:
> +			var->bits_per_pixel = 32;
> +			break;
> +		default:
> +			return -EINVAL;
> +		}
> +
> +		memset(var->format.reserved, 0, sizeof(var->format.reserved));

If we decide to use another of the reserved area this won't have the desired
behavior as the behavior of this driver will change even if it does not support
the new field. Probably the best thing is to get the desired behavior is zeroing
the whole struct and setting the supported fields to the actual values.
You should check and adjust colorspace here as well.

> +	} else {
> +		if (var->bits_per_pixel <= 16) {		/* RGB 565 */
> +			var->bits_per_pixel = 16;
> +			var->red.offset = 11;
> +			var->red.length = 5;
> +			var->green.offset = 5;
> +			var->green.length = 6;
> +			var->blue.offset = 0;
> +			var->blue.length = 5;
> +			var->transp.offset = 0;
> +			var->transp.length = 0;
> +		} else if (var->bits_per_pixel <= 24) {		/* RGB 888 */
> +			var->bits_per_pixel = 24;
> +			var->red.offset = 16;
> +			var->red.length = 8;
> +			var->green.offset = 8;
> +			var->green.length = 8;
> +			var->blue.offset = 0;
> +			var->blue.length = 8;
> +			var->transp.offset = 0;
> +			var->transp.length = 0;
> +		} else if (var->bits_per_pixel <= 32) {		/* RGBA 888 */
> +			var->bits_per_pixel = 32;
> +			var->red.offset = 16;
> +			var->red.length = 8;
> +			var->green.offset = 8;
> +			var->green.length = 8;
> +			var->blue.offset = 0;
> +			var->blue.length = 8;
> +			var->transp.offset = 24;
> +			var->transp.length = 8;
> +		} else
> +			return -EINVAL;
>  
> -	var->red.msb_right = 0;
> -	var->green.msb_right = 0;
> -	var->blue.msb_right = 0;
> -	var->transp.msb_right = 0;
> +		var->red.msb_right = 0;
> +		var->green.msb_right = 0;
> +		var->blue.msb_right = 0;
> +		var->transp.msb_right = 0;
> +	}
>  
>  	/* Make sure we don't exceed our allocated memory. */
>  	if (var->xres_virtual * var->yres_virtual * var->bits_per_pixel / 8 >
>  	    info->fix.smem_len)
>  		return -EINVAL;
>  
> -	/* only accept the forced_bpp for dual channel configurations */
> -	if (p->forced_bpp && p->forced_bpp != var->bits_per_pixel)
> +	/* only accept the forced_fourcc for dual channel configurations */
> +	if (p->forced_fourcc &&
> +	    p->forced_fourcc != sh_mobile_format_fourcc(var))
>  		return -EINVAL;
>  
>  	return 0;
> @@ -1157,7 +1239,7 @@ static int sh_mobile_set_par(struct fb_info *info)
>  
>  	sh_mobile_lcdc_stop(ch->lcdc);
>  
> -	if (info->var.nonstd)
> +	if (sh_mobile_format_yuv(&info->var))
>  		info->fix.line_length = info->var.xres;
>  	else
>  		info->fix.line_length = info->var.xres
> @@ -1169,6 +1251,11 @@ static int sh_mobile_set_par(struct fb_info *info)
>  		info->fix.line_length = line_length;
>  	}
>  
> +	if (info->var.format.fourcc > 1)
> +		info->fix.visual = FB_VISUAL_FOURCC;
> +	else
> +		info->fix.visual = FB_VISUAL_TRUECOLOR;
> +
>  	return ret;
>  }
>  
> @@ -1463,9 +1550,9 @@ static int __devinit sh_mobile_lcdc_channel_init(struct sh_mobile_lcdc_chan *ch,
>  	for (i = 0, mode = cfg->lcd_cfg; i < cfg->num_cfg; i++, mode++) {
>  		unsigned int size = mode->yres * mode->xres;
>  
> -		/* NV12 buffers must have even number of lines */
> -		if ((cfg->nonstd) && cfg->bpp = 12 &&
> -				(mode->yres & 0x1)) {
> +		/* NV12/NV21 buffers must have even number of lines */
> +		if ((cfg->fourcc = V4L2_PIX_FMT_NV12 ||
> +		     cfg->fourcc = V4L2_PIX_FMT_NV21) && (mode->yres & 0x1)) {
>  			dev_err(dev, "yres must be multiple of 2 for YCbCr420 "
>  				"mode.\n");
>  			return -EINVAL;
> @@ -1483,14 +1570,6 @@ static int __devinit sh_mobile_lcdc_channel_init(struct sh_mobile_lcdc_chan *ch,
>  		dev_dbg(dev, "Found largest videomode %ux%u\n",
>  			max_mode->xres, max_mode->yres);
>  
> -	/* Initialize fixed screen information. Restrict pan to 2 lines steps
> -	 * for NV12.
> -	 */
> -	info->fix = sh_mobile_lcdc_fix;
> -	info->fix.smem_len = max_size * 2 * cfg->bpp / 8;
> -	if (cfg->nonstd && cfg->bpp = 12)
> -		info->fix.ypanstep = 2;
> -
>  	/* Create the mode list. */
>  	if (cfg->lcd_cfg = NULL) {
>  		mode = &default_720p;
> @@ -1508,19 +1587,38 @@ static int __devinit sh_mobile_lcdc_channel_init(struct sh_mobile_lcdc_chan *ch,
>  	 */
>  	var = &info->var;
>  	fb_videomode_to_var(var, mode);
> -	var->bits_per_pixel = cfg->bpp;
>  	var->width = cfg->lcd_size_cfg.width;
>  	var->height = cfg->lcd_size_cfg.height;
>  	var->yres_virtual = var->yres * 2;
>  	var->activate = FB_ACTIVATE_NOW;
>  
> +	switch (cfg->fourcc) {
> +	case V4L2_PIX_FMT_RGB565:
> +		var->bits_per_pixel = 16;
> +		break;
> +	case V4L2_PIX_FMT_BGR24:
> +		var->bits_per_pixel = 24;
> +		break;
> +	case V4L2_PIX_FMT_BGR32:
> +		var->bits_per_pixel = 32;
> +		break;
> +	default:
> +		var->format.fourcc = cfg->fourcc;
> +		break;
> +	}
> +
> +	/* Make sure the memory size check won't fail. smem_len is initialized
> +	 * later based on var.
> +	 */
> +	info->fix.smem_len = UINT_MAX;
>  	ret = sh_mobile_check_var(var, info);
>  	if (ret)
>  		return ret;
>  
> +	max_size *= var->bits_per_pixel / 8 * 2;
> +
>  	/* Allocate frame buffer memory and color map. */
> -	buf = dma_alloc_coherent(dev, info->fix.smem_len, &ch->dma_handle,
> -				 GFP_KERNEL);
> +	buf = dma_alloc_coherent(dev, max_size, &ch->dma_handle, GFP_KERNEL);
>  	if (!buf) {
>  		dev_err(dev, "unable to allocate buffer\n");
>  		return -ENOMEM;
> @@ -1529,16 +1627,25 @@ static int __devinit sh_mobile_lcdc_channel_init(struct sh_mobile_lcdc_chan *ch,
>  	ret = fb_alloc_cmap(&info->cmap, PALETTE_NR, 0);
>  	if (ret < 0) {
>  		dev_err(dev, "unable to allocate cmap\n");
> -		dma_free_coherent(dev, info->fix.smem_len,
> -				  buf, ch->dma_handle);
> +		dma_free_coherent(dev, max_size, buf, ch->dma_handle);
>  		return ret;
>  	}
>  
> +	/* Initialize fixed screen information. Restrict pan to 2 lines steps
> +	 * for NV12 and NV21.
> +	 */
> +	info->fix = sh_mobile_lcdc_fix;
>  	info->fix.smem_start = ch->dma_handle;
> -	if (var->nonstd)
> +	info->fix.smem_len = max_size * var->bits_per_pixel / 8 * 2;
> +	if (cfg->fourcc = V4L2_PIX_FMT_NV12 ||
> +	    cfg->fourcc = V4L2_PIX_FMT_NV21)
> +		info->fix.ypanstep = 2;
> +
> +	if (sh_mobile_format_yuv(var))
>  		info->fix.line_length = var->xres;
>  	else
> -		info->fix.line_length = var->xres * (cfg->bpp / 8);
> +		info->fix.line_length = var->xres * var->bits_per_pixel
> +				      / 8;
>  
>  	info->screen_base = buf;
>  	info->device = dev;
> @@ -1625,9 +1732,9 @@ static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev)
>  		goto err1;
>  	}
>  
> -	/* for dual channel LCDC (MAIN + SUB) force shared bpp setting */
> +	/* for dual channel LCDC (MAIN + SUB) force shared format setting */
>  	if (num_channels = 2)
> -		priv->forced_bpp = pdata->ch[0].bpp;
> +		priv->forced_fourcc = pdata->ch[0].fourcc;
>  
>  	priv->base = ioremap_nocache(res->start, resource_size(res));
>  	if (!priv->base)
> @@ -1674,13 +1781,10 @@ static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev)
>  		if (error < 0)
>  			goto err1;
>  
> -		dev_info(info->dev,
> -			 "registered %s/%s as %dx%d %dbpp.\n",
> -			 pdev->name,
> -			 (ch->cfg.chan = LCDC_CHAN_MAINLCD) ?
> -			 "mainlcd" : "sublcd",
> -			 info->var.xres, info->var.yres,
> -			 ch->cfg.bpp);
> +		dev_info(info->dev, "registered %s/%s as %dx%d %dbpp.\n",
> +			 pdev->name, (ch->cfg.chan = LCDC_CHAN_MAINLCD) ?
> +			 "mainlcd" : "sublcd", info->var.xres, info->var.yres,
> +			 info->var.bits_per_pixel);
>  
>  		/* deferred io mode: disable clock to save power */
>  		if (info->fbdefio || info->state = FBINFO_STATE_SUSPENDED)
> diff --git a/include/video/sh_mobile_lcdc.h b/include/video/sh_mobile_lcdc.h
> index 8101b72..fe30b75 100644
> --- a/include/video/sh_mobile_lcdc.h
> +++ b/include/video/sh_mobile_lcdc.h
> @@ -174,7 +174,8 @@ struct sh_mobile_lcdc_bl_info {
>  
>  struct sh_mobile_lcdc_chan_cfg {
>  	int chan;
> -	int bpp;
> +	int fourcc;
> +	int colorspace;
>  	int interface_type; /* selects RGBn or SYSn I/F, see above */
>  	int clock_divider;
>  	unsigned long flags; /* LCDC_FLAGS_... */
> @@ -184,7 +185,6 @@ struct sh_mobile_lcdc_chan_cfg {
>  	struct sh_mobile_lcdc_board_cfg board_cfg;
>  	struct sh_mobile_lcdc_bl_info bl_info;
>  	struct sh_mobile_lcdc_sys_bus_cfg sys_bus_cfg; /* only for SYSn I/F */
> -	int nonstd;
>  	struct sh_mobile_meram_cfg *meram_cfg;
>  };
>  


Thanks,

Florian Tobias Schandinat

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
  2011-08-26 17:07     ` [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration Florian Tobias Schandinat
@ 2011-08-28  8:48       ` Laurent Pinchart
  -1 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-28  8:48 UTC (permalink / raw)
  To: Florian Tobias Schandinat; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Florian,

Thank you for the review.

On Friday 26 August 2011 19:07:01 Florian Tobias Schandinat wrote:
> Hi Laurent,
> 
> hope we're close to the final thing now. Just a few minor issues.

I agree with all your comments, I'll fix the patches accordingly.

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
@ 2011-08-28  8:48       ` Laurent Pinchart
  0 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-28  8:48 UTC (permalink / raw)
  To: Florian Tobias Schandinat; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Florian,

Thank you for the review.

On Friday 26 August 2011 19:07:01 Florian Tobias Schandinat wrote:
> Hi Laurent,
> 
> hope we're close to the final thing now. Just a few minor issues.

I agree with all your comments, I'll fix the patches accordingly.

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 3/3] fbdev: sh_mobile_lcdc: Support FOURCC-based format API
  2011-08-26 17:24     ` [PATCH/RFC v2 3/3] fbdev: sh_mobile_lcdc: Support FOURCC-based Florian Tobias Schandinat
@ 2011-08-28  8:59       ` Laurent Pinchart
  -1 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-28  8:59 UTC (permalink / raw)
  To: Florian Tobias Schandinat; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Florian,

Thanks for the review.

On Friday 26 August 2011 19:24:02 Florian Tobias Schandinat wrote:
> On 08/19/2011 09:37 AM, Laurent Pinchart wrote:

[snip]

> > diff --git a/drivers/video/sh_mobile_lcdcfb.c
> > b/drivers/video/sh_mobile_lcdcfb.c index 97ab8ba..ea3f619 100644
> > --- a/drivers/video/sh_mobile_lcdcfb.c
> > +++ b/drivers/video/sh_mobile_lcdcfb.c

[snip]

> > @@ -1099,51 +1154,78 @@ static int sh_mobile_check_var(struct

[snip]

> > +	if (var->format.fourcc > 1) {
> > +		switch (var->format.fourcc) {
> > +		case V4L2_PIX_FMT_NV12:
> > +		case V4L2_PIX_FMT_NV21:
> > +			var->bits_per_pixel = 12;
> > +			break;
> > +		case V4L2_PIX_FMT_RGB565:
> > +		case V4L2_PIX_FMT_NV16:
> > +		case V4L2_PIX_FMT_NV61:
> > +			var->bits_per_pixel = 16;
> > +			break;
> > +		case V4L2_PIX_FMT_BGR24:
> > +		case V4L2_PIX_FMT_NV24:
> > +		case V4L2_PIX_FMT_NV42:
> > +			var->bits_per_pixel = 24;
> > +			break;
> > +		case V4L2_PIX_FMT_BGR32:
> > +			var->bits_per_pixel = 32;
> > +			break;
> > +		default:
> > +			return -EINVAL;
> > +		}
> > +
> > +		memset(var->format.reserved, 0, sizeof(var->format.reserved));
> 
> If we decide to use another of the reserved area this won't have the
> desired behavior as the behavior of this driver will change even if it
> does not support the new field. Probably the best thing is to get the
> desired behavior is zeroing the whole struct and setting the supported
> fields to the actual values. You should check and adjust colorspace here
> as well.

Agreed. I'll fix the patch accordingly.

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 3/3] fbdev: sh_mobile_lcdc: Support FOURCC-based format API
@ 2011-08-28  8:59       ` Laurent Pinchart
  0 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-28  8:59 UTC (permalink / raw)
  To: Florian Tobias Schandinat; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Florian,

Thanks for the review.

On Friday 26 August 2011 19:24:02 Florian Tobias Schandinat wrote:
> On 08/19/2011 09:37 AM, Laurent Pinchart wrote:

[snip]

> > diff --git a/drivers/video/sh_mobile_lcdcfb.c
> > b/drivers/video/sh_mobile_lcdcfb.c index 97ab8ba..ea3f619 100644
> > --- a/drivers/video/sh_mobile_lcdcfb.c
> > +++ b/drivers/video/sh_mobile_lcdcfb.c

[snip]

> > @@ -1099,51 +1154,78 @@ static int sh_mobile_check_var(struct

[snip]

> > +	if (var->format.fourcc > 1) {
> > +		switch (var->format.fourcc) {
> > +		case V4L2_PIX_FMT_NV12:
> > +		case V4L2_PIX_FMT_NV21:
> > +			var->bits_per_pixel = 12;
> > +			break;
> > +		case V4L2_PIX_FMT_RGB565:
> > +		case V4L2_PIX_FMT_NV16:
> > +		case V4L2_PIX_FMT_NV61:
> > +			var->bits_per_pixel = 16;
> > +			break;
> > +		case V4L2_PIX_FMT_BGR24:
> > +		case V4L2_PIX_FMT_NV24:
> > +		case V4L2_PIX_FMT_NV42:
> > +			var->bits_per_pixel = 24;
> > +			break;
> > +		case V4L2_PIX_FMT_BGR32:
> > +			var->bits_per_pixel = 32;
> > +			break;
> > +		default:
> > +			return -EINVAL;
> > +		}
> > +
> > +		memset(var->format.reserved, 0, sizeof(var->format.reserved));
> 
> If we decide to use another of the reserved area this won't have the
> desired behavior as the behavior of this driver will change even if it
> does not support the new field. Probably the best thing is to get the
> desired behavior is zeroing the whole struct and setting the supported
> fields to the actual values. You should check and adjust colorspace here
> as well.

Agreed. I'll fix the patch accordingly.

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 3/3] fbdev: sh_mobile_lcdc: Support FOURCC-based format API
  2011-08-19  9:37   ` Laurent Pinchart
@ 2011-08-29  0:39     ` Magnus Damm
  -1 siblings, 0 replies; 52+ messages in thread
From: Magnus Damm @ 2011-08-29  0:39 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-fbdev, linux-media

On Fri, Aug 19, 2011 at 6:37 PM, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  arch/arm/mach-shmobile/board-ag5evm.c   |    2 +-
>  arch/arm/mach-shmobile/board-ap4evb.c   |    4 +-
>  arch/arm/mach-shmobile/board-mackerel.c |    4 +-
>  drivers/video/sh_mobile_lcdcfb.c        |  342 ++++++++++++++++++++-----------
>  include/video/sh_mobile_lcdc.h          |    4 +-
>  5 files changed, 230 insertions(+), 126 deletions(-)

Hi Laurent, thanks for the patch!

Since you're changing the LCDC platform data please make sure you also
update the 5 boards using the LCDC under arch/sh.

Thanks,

/ magnus

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 3/3] fbdev: sh_mobile_lcdc: Support FOURCC-based
@ 2011-08-29  0:39     ` Magnus Damm
  0 siblings, 0 replies; 52+ messages in thread
From: Magnus Damm @ 2011-08-29  0:39 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-fbdev, linux-media

On Fri, Aug 19, 2011 at 6:37 PM, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  arch/arm/mach-shmobile/board-ag5evm.c   |    2 +-
>  arch/arm/mach-shmobile/board-ap4evb.c   |    4 +-
>  arch/arm/mach-shmobile/board-mackerel.c |    4 +-
>  drivers/video/sh_mobile_lcdcfb.c        |  342 ++++++++++++++++++++-----------
>  include/video/sh_mobile_lcdc.h          |    4 +-
>  5 files changed, 230 insertions(+), 126 deletions(-)

Hi Laurent, thanks for the patch!

Since you're changing the LCDC platform data please make sure you also
update the 5 boards using the LCDC under arch/sh.

Thanks,

/ magnus

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
  2011-08-19  9:37   ` Laurent Pinchart
@ 2011-08-29  8:13     ` Geert Uytterhoeven
  -1 siblings, 0 replies; 52+ messages in thread
From: Geert Uytterhoeven @ 2011-08-29  8:13 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Laurent,

My comments are mainly about the documentation of the "legacy" bits.

On Fri, Aug 19, 2011 at 11:37, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> diff --git a/Documentation/fb/api.txt b/Documentation/fb/api.txt
> new file mode 100644
> index 0000000..6808492
> --- /dev/null
> +++ b/Documentation/fb/api.txt

> +2. Types and visuals
> +--------------------
> +
> +Pixels are stored in memory in hardware-dependent formats. Applications need
> +to be aware of the pixel storage format in order to write image data to the
> +frame buffer memory in the format expected by the hardware.
> +
> +Formats are described by frame buffer types and visuals. Some visuals require
> +additional information, which are stored in the variable screen information
> +bits_per_pixel, grayscale, fourcc, red, green, blue and transp fields.
> +
> +The following types and visuals are supported.
> +
> +- FB_TYPE_PACKED_PIXELS
> +
> +Color components (usually RGB or YUV) are packed together into macropixels
> +that are stored in a single plane. The exact color components layout is
> +described in a visual-dependent way.
> +
> +Frame buffer visuals that don't use multiple color components per pixel
> +(such as monochrome and pseudo-color visuals) are reported as packed frame
> +buffer types, even though they don't stricly speaking pack color components
> +into macropixels.

That's because the "packing" is not about the color components, but about the
bits that represent a single pixel.

I.e. the bits that make up the pixel (the macropixel) are stored next
to each other
in memory.

> +- FB_TYPE_PLANES
> +
> +Color components are stored in separate planes. Planes are located
> +contiguously in memory.

The bits that make up a pixel are stored in separate planes. Planes are located
contiguously in memory.

- FB_TYPE_INTERLEAVED_PLANES

The bits that make up a pixel are stored in separate planes. Planes
are interleaved.
The interleave factor (the distance in bytes between the planes in
memory) is stored
in the type_aux field.

> +- FB_VISUAL_MONO01
> +
> +Pixels are black or white and stored on one bit. A bit set to 1 represents a
> +black pixel and a bit set to 0 a white pixel. Pixels are packed together in
> +bytes with 8 pixels per byte.

Actually we do have drivers that use 8 bits per pixel for a monochrome visual.
Hence:

"Pixels are black or white. A black pixel is represented by all
(typically one) bits
set to ones, a white pixel by all bits set to zeroes."

> +FB_VISUAL_MONO01 is used with FB_TYPE_PACKED_PIXELS only.

... so this may also not be true (but it is for all current drivers, IIRC).
There's a strict orthogonality between type (how is a pixel stored in memory)
and visual (how the bits that represent the pixel are interpreted and converted
to a color value).

Same comments for FB_VISUAL_MONO10

> +- FB_VISUAL_TRUECOLOR
> +
> +Pixels are broken into red, green and blue components, and each component
> +indexes a read-only lookup table for the corresponding value. Lookup tables
> +are device-dependent, and provide linear or non-linear ramps.
> +
> +Each component is stored in memory according to the variable screen
> +information red, green, blue and transp fields.

"Each component is stored in a macropixel according to the variable screen
information red, green, blue and transp fields."

Storage format in memory is determined by the FB_TYPE_* value.

> +- FB_VISUAL_PSEUDOCOLOR and FB_VISUAL_STATIC_PSEUDOCOLOR
> +
> +Pixel values are encoded as indices into a colormap that stores red, green and
> +blue components. The colormap is read-only for FB_VISUAL_STATIC_PSEUDOCOLOR
> +and read-write for FB_VISUAL_PSEUDOCOLOR.
> +
> +Each pixel value is stored in the number of bits reported by the variable
> +screen information bits_per_pixel field. Pixels are contiguous in memory.

Whether pixels are contiguous in memory or not is determined by the
FB_TYPE_* value.

> +FB_VISUAL_PSEUDOCOLOR and FB_VISUAL_STATIC_PSEUDOCOLOR are used with
> +FB_TYPE_PACKED_PIXELS only.

Not true. Several drivers use bit planes or interleaved bitplanes.

> +- FB_VISUAL_DIRECTCOLOR
> +
> +Pixels are broken into red, green and blue components, and each component
> +indexes a programmable lookup table for the corresponding value.
> +
> +Each component is stored in memory according to the variable screen
> +information red, green, blue and transp fields.

"Each component is stored in a macropixel according to the variable screen
information red, green, blue and transp fields."

> +- FB_VISUAL_FOURCC
> +
> +Pixels are stored in memory as described by the format FOURCC identifier
> +stored in the variable screen information fourcc field.

... stored in memory and interpreted ...

> +struct fb_var_screeninfo {
> +       __u32 xres;                     /* visible resolution           */
> +       __u32 yres;
> +       __u32 xres_virtual;             /* virtual resolution           */
> +       __u32 yres_virtual;
> +       __u32 xoffset;                  /* offset from virtual to visible */
> +       __u32 yoffset;                  /* resolution                   */
> +
> +       __u32 bits_per_pixel;           /* guess what                   */
> +       union {
> +               struct {                /* Legacy format API            */
> +                       __u32 grayscale; /* != 0 Graylevels instead of colors */
> +                       /* bitfields in fb mem if true color, else only */
> +                       /* length is significant                        */
> +                       struct fb_bitfield red;
> +                       struct fb_bitfield green;
> +                       struct fb_bitfield blue;
> +                       struct fb_bitfield transp;      /* transparency */
> +               };
> +               struct {                /* FOURCC-based format API      */
> +                       __u32 fourcc;           /* FOURCC format        */
> +                       __u32 colorspace;
> +                       __u32 reserved[11];
> +               } format;
> +       };
> +
> +       struct fb_bitfield red;         /* bitfield in fb mem if true color, */
> +       struct fb_bitfield green;       /* else only length is significant */
> +       struct fb_bitfield blue;
> +       struct fb_bitfield transp;      /* transparency                 */

These four are duplicated, cfr. the union above.

> +  Pixel values are bits_per_pixel wide and are split in non-overlapping red,
> +  green, blue and alpha (transparency) components. Location and size of each
> +  component in the pixel value are described by the fb_bitfield offset and
> +  length fields. Offset are computed from the right.

                   Offsets

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
@ 2011-08-29  8:13     ` Geert Uytterhoeven
  0 siblings, 0 replies; 52+ messages in thread
From: Geert Uytterhoeven @ 2011-08-29  8:13 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Laurent,

My comments are mainly about the documentation of the "legacy" bits.

On Fri, Aug 19, 2011 at 11:37, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> diff --git a/Documentation/fb/api.txt b/Documentation/fb/api.txt
> new file mode 100644
> index 0000000..6808492
> --- /dev/null
> +++ b/Documentation/fb/api.txt

> +2. Types and visuals
> +--------------------
> +
> +Pixels are stored in memory in hardware-dependent formats. Applications need
> +to be aware of the pixel storage format in order to write image data to the
> +frame buffer memory in the format expected by the hardware.
> +
> +Formats are described by frame buffer types and visuals. Some visuals require
> +additional information, which are stored in the variable screen information
> +bits_per_pixel, grayscale, fourcc, red, green, blue and transp fields.
> +
> +The following types and visuals are supported.
> +
> +- FB_TYPE_PACKED_PIXELS
> +
> +Color components (usually RGB or YUV) are packed together into macropixels
> +that are stored in a single plane. The exact color components layout is
> +described in a visual-dependent way.
> +
> +Frame buffer visuals that don't use multiple color components per pixel
> +(such as monochrome and pseudo-color visuals) are reported as packed frame
> +buffer types, even though they don't stricly speaking pack color components
> +into macropixels.

That's because the "packing" is not about the color components, but about the
bits that represent a single pixel.

I.e. the bits that make up the pixel (the macropixel) are stored next
to each other
in memory.

> +- FB_TYPE_PLANES
> +
> +Color components are stored in separate planes. Planes are located
> +contiguously in memory.

The bits that make up a pixel are stored in separate planes. Planes are located
contiguously in memory.

- FB_TYPE_INTERLEAVED_PLANES

The bits that make up a pixel are stored in separate planes. Planes
are interleaved.
The interleave factor (the distance in bytes between the planes in
memory) is stored
in the type_aux field.

> +- FB_VISUAL_MONO01
> +
> +Pixels are black or white and stored on one bit. A bit set to 1 represents a
> +black pixel and a bit set to 0 a white pixel. Pixels are packed together in
> +bytes with 8 pixels per byte.

Actually we do have drivers that use 8 bits per pixel for a monochrome visual.
Hence:

"Pixels are black or white. A black pixel is represented by all
(typically one) bits
set to ones, a white pixel by all bits set to zeroes."

> +FB_VISUAL_MONO01 is used with FB_TYPE_PACKED_PIXELS only.

... so this may also not be true (but it is for all current drivers, IIRC).
There's a strict orthogonality between type (how is a pixel stored in memory)
and visual (how the bits that represent the pixel are interpreted and converted
to a color value).

Same comments for FB_VISUAL_MONO10

> +- FB_VISUAL_TRUECOLOR
> +
> +Pixels are broken into red, green and blue components, and each component
> +indexes a read-only lookup table for the corresponding value. Lookup tables
> +are device-dependent, and provide linear or non-linear ramps.
> +
> +Each component is stored in memory according to the variable screen
> +information red, green, blue and transp fields.

"Each component is stored in a macropixel according to the variable screen
information red, green, blue and transp fields."

Storage format in memory is determined by the FB_TYPE_* value.

> +- FB_VISUAL_PSEUDOCOLOR and FB_VISUAL_STATIC_PSEUDOCOLOR
> +
> +Pixel values are encoded as indices into a colormap that stores red, green and
> +blue components. The colormap is read-only for FB_VISUAL_STATIC_PSEUDOCOLOR
> +and read-write for FB_VISUAL_PSEUDOCOLOR.
> +
> +Each pixel value is stored in the number of bits reported by the variable
> +screen information bits_per_pixel field. Pixels are contiguous in memory.

Whether pixels are contiguous in memory or not is determined by the
FB_TYPE_* value.

> +FB_VISUAL_PSEUDOCOLOR and FB_VISUAL_STATIC_PSEUDOCOLOR are used with
> +FB_TYPE_PACKED_PIXELS only.

Not true. Several drivers use bit planes or interleaved bitplanes.

> +- FB_VISUAL_DIRECTCOLOR
> +
> +Pixels are broken into red, green and blue components, and each component
> +indexes a programmable lookup table for the corresponding value.
> +
> +Each component is stored in memory according to the variable screen
> +information red, green, blue and transp fields.

"Each component is stored in a macropixel according to the variable screen
information red, green, blue and transp fields."

> +- FB_VISUAL_FOURCC
> +
> +Pixels are stored in memory as described by the format FOURCC identifier
> +stored in the variable screen information fourcc field.

... stored in memory and interpreted ...

> +struct fb_var_screeninfo {
> +       __u32 xres;                     /* visible resolution           */
> +       __u32 yres;
> +       __u32 xres_virtual;             /* virtual resolution           */
> +       __u32 yres_virtual;
> +       __u32 xoffset;                  /* offset from virtual to visible */
> +       __u32 yoffset;                  /* resolution                   */
> +
> +       __u32 bits_per_pixel;           /* guess what                   */
> +       union {
> +               struct {                /* Legacy format API            */
> +                       __u32 grayscale; /* != 0 Graylevels instead of colors */
> +                       /* bitfields in fb mem if true color, else only */
> +                       /* length is significant                        */
> +                       struct fb_bitfield red;
> +                       struct fb_bitfield green;
> +                       struct fb_bitfield blue;
> +                       struct fb_bitfield transp;      /* transparency */
> +               };
> +               struct {                /* FOURCC-based format API      */
> +                       __u32 fourcc;           /* FOURCC format        */
> +                       __u32 colorspace;
> +                       __u32 reserved[11];
> +               } format;
> +       };
> +
> +       struct fb_bitfield red;         /* bitfield in fb mem if true color, */
> +       struct fb_bitfield green;       /* else only length is significant */
> +       struct fb_bitfield blue;
> +       struct fb_bitfield transp;      /* transparency                 */

These four are duplicated, cfr. the union above.

> +  Pixel values are bits_per_pixel wide and are split in non-overlapping red,
> +  green, blue and alpha (transparency) components. Location and size of each
> +  component in the pixel value are described by the fb_bitfield offset and
> +  length fields. Offset are computed from the right.

                   Offsets

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 3/3] fbdev: sh_mobile_lcdc: Support FOURCC-based format API
  2011-08-29  0:39     ` [PATCH/RFC v2 3/3] fbdev: sh_mobile_lcdc: Support FOURCC-based Magnus Damm
@ 2011-08-29  8:30       ` Laurent Pinchart
  -1 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-29  8:30 UTC (permalink / raw)
  To: Magnus Damm; +Cc: linux-fbdev, linux-media

Hi Magnus,

On Monday 29 August 2011 02:39:06 Magnus Damm wrote:
> On Fri, Aug 19, 2011 at 6:37 PM, Laurent Pinchart wrote:
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >  arch/arm/mach-shmobile/board-ag5evm.c   |    2 +-
> >  arch/arm/mach-shmobile/board-ap4evb.c   |    4 +-
> >  arch/arm/mach-shmobile/board-mackerel.c |    4 +-
> >  drivers/video/sh_mobile_lcdcfb.c        |  342
> > ++++++++++++++++++++----------- include/video/sh_mobile_lcdc.h        
> >  |    4 +-
> >  5 files changed, 230 insertions(+), 126 deletions(-)
> 
> Hi Laurent, thanks for the patch!
> 
> Since you're changing the LCDC platform data please make sure you also
> update the 5 boards using the LCDC under arch/sh.

Sure. Sorry for forgetting about that.

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 3/3] fbdev: sh_mobile_lcdc: Support FOURCC-based format API
@ 2011-08-29  8:30       ` Laurent Pinchart
  0 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-29  8:30 UTC (permalink / raw)
  To: Magnus Damm; +Cc: linux-fbdev, linux-media

Hi Magnus,

On Monday 29 August 2011 02:39:06 Magnus Damm wrote:
> On Fri, Aug 19, 2011 at 6:37 PM, Laurent Pinchart wrote:
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >  arch/arm/mach-shmobile/board-ag5evm.c   |    2 +-
> >  arch/arm/mach-shmobile/board-ap4evb.c   |    4 +-
> >  arch/arm/mach-shmobile/board-mackerel.c |    4 +-
> >  drivers/video/sh_mobile_lcdcfb.c        |  342
> > ++++++++++++++++++++----------- include/video/sh_mobile_lcdc.h        
> >  |    4 +-
> >  5 files changed, 230 insertions(+), 126 deletions(-)
> 
> Hi Laurent, thanks for the patch!
> 
> Since you're changing the LCDC platform data please make sure you also
> update the 5 boards using the LCDC under arch/sh.

Sure. Sorry for forgetting about that.

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
  2011-08-29  8:13     ` Geert Uytterhoeven
@ 2011-08-29  8:50       ` Laurent Pinchart
  -1 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-29  8:50 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Geert,

Thanks for the review.

On Monday 29 August 2011 10:13:07 Geert Uytterhoeven wrote:
> On Fri, Aug 19, 2011 at 11:37, Laurent Pinchart wrote:

[snip]

> > +- FB_TYPE_PACKED_PIXELS
> > +
> > +Color components (usually RGB or YUV) are packed together into
> > macropixels +that are stored in a single plane. The exact color
> > components layout is +described in a visual-dependent way.
> > +
> > +Frame buffer visuals that don't use multiple color components per pixel
> > +(such as monochrome and pseudo-color visuals) are reported as packed
> > frame +buffer types, even though they don't stricly speaking pack color
> > components +into macropixels.
> 
> That's because the "packing" is not about the color components, but about
> the bits that represent a single pixel.
> 
> I.e. the bits that make up the pixel (the macropixel) are stored next
> to each other
> in memory.

OK, I've modified that last sentence to read

"Frame buffer visuals that don't use multiple color components per pixel (such 
as monochrome and pseudo-color visuals) are also reported as packed frame
buffer types, as the bits that make up individual pixels are packed next to
each other in memory."

> > +- FB_TYPE_PLANES
> > +
> > +Color components are stored in separate planes. Planes are located
> > +contiguously in memory.
> 
> The bits that make up a pixel are stored in separate planes. Planes are
> located contiguously in memory.

I'm not sure to agree with this. You make it sounds like FB_TYPE_PLANES stores 
each bit in a different plane. Is that really the case ?

> - FB_TYPE_INTERLEAVED_PLANES
> 
> The bits that make up a pixel are stored in separate planes. Planes
> are interleaved.
> The interleave factor (the distance in bytes between the planes in
> memory) is stored in the type_aux field.

That's a bit unclear to me. How are they interleaved ?

> > +- FB_VISUAL_MONO01
> > +
> > +Pixels are black or white and stored on one bit. A bit set to 1
> > represents a +black pixel and a bit set to 0 a white pixel. Pixels are
> > packed together in +bytes with 8 pixels per byte.
> 
> Actually we do have drivers that use 8 bits per pixel for a monochrome
> visual. Hence:
> 
> "Pixels are black or white. A black pixel is represented by all
> (typically one) bits set to ones, a white pixel by all bits set to zeroes."

OK. I've rephrased it as

"Pixels are black or white and stored on a number of bits (typically one)
specified by the variable screen information bpp field. 

Black pixels are represented by all bits set to 1 and white pixels by all bits
set to 0. When the number of bits per pixel is smaller than 8, several pixels 
are packed together in a byte."

> > +FB_VISUAL_MONO01 is used with FB_TYPE_PACKED_PIXELS only.
> 
> ... so this may also not be true (but it is for all current drivers, IIRC).
> There's a strict orthogonality between type (how is a pixel stored in
> memory) and visual (how the bits that represent the pixel are interpreted
> and converted to a color value).

What about

"FB_VISUAL_MONO01 is currently used with FB_TYPE_PACKED_PIXELS only." ?

> Same comments for FB_VISUAL_MONO10

Fixed the same way.

> > +- FB_VISUAL_TRUECOLOR
> > +
> > +Pixels are broken into red, green and blue components, and each
> > component +indexes a read-only lookup table for the corresponding value.
> > Lookup tables +are device-dependent, and provide linear or non-linear
> > ramps.
> > +
> > +Each component is stored in memory according to the variable screen
> > +information red, green, blue and transp fields.
> 
> "Each component is stored in a macropixel according to the variable screen
> information red, green, blue and transp fields."
> 
> Storage format in memory is determined by the FB_TYPE_* value.

How so ? With FB_TYPE_PLANES and FB_VISUAL_TRUECOLOR for an RGB format, how 
are the R, G and B planes ordered ? Are color components packed or padded 
inside a plane ? I understand that the design goal was to have orthogonal 
FB_TYPE_* and FB_VISUAL_* values, but we're missing too much information for 
that to be truly generic.

> > +- FB_VISUAL_PSEUDOCOLOR and FB_VISUAL_STATIC_PSEUDOCOLOR
> > +
> > +Pixel values are encoded as indices into a colormap that stores red,
> > green and +blue components. The colormap is read-only for
> > FB_VISUAL_STATIC_PSEUDOCOLOR +and read-write for FB_VISUAL_PSEUDOCOLOR.
> > +
> > +Each pixel value is stored in the number of bits reported by the
> > variable +screen information bits_per_pixel field. Pixels are contiguous
> > in memory.
> 
> Whether pixels are contiguous in memory or not is determined by the
> FB_TYPE_* value.

How can they not be contiguous in memory ? Can you please give an example ?

> > +FB_VISUAL_PSEUDOCOLOR and FB_VISUAL_STATIC_PSEUDOCOLOR are used with
> > +FB_TYPE_PACKED_PIXELS only.
> 
> Not true. Several drivers use bit planes or interleaved bitplanes.

How does that work ?

> > +- FB_VISUAL_DIRECTCOLOR
> > +
> > +Pixels are broken into red, green and blue components, and each
> > component +indexes a programmable lookup table for the corresponding
> > value. +
> > +Each component is stored in memory according to the variable screen
> > +information red, green, blue and transp fields.
> 
> "Each component is stored in a macropixel according to the variable screen
> information red, green, blue and transp fields."
> 
> > +- FB_VISUAL_FOURCC
> > +
> > +Pixels are stored in memory as described by the format FOURCC identifier
> > +stored in the variable screen information fourcc field.
> 
> ... stored in memory and interpreted ...
> 
> > +struct fb_var_screeninfo {
> > +       __u32 xres;                     /* visible resolution          
> > */ +       __u32 yres;
> > +       __u32 xres_virtual;             /* virtual resolution          
> > */ +       __u32 yres_virtual;
> > +       __u32 xoffset;                  /* offset from virtual to visible
> > */ +       __u32 yoffset;                  /* resolution                
> >   */ +
> > +       __u32 bits_per_pixel;           /* guess what                  
> > */ +       union {
> > +               struct {                /* Legacy format API          
> >  */ +                       __u32 grayscale; /* != 0 Graylevels instead
> > of colors */ +                       /* bitfields in fb mem if true
> > color, else only */ +                       /* length is significant    
> >                    */ +                       struct fb_bitfield red;
> > +                       struct fb_bitfield green;
> > +                       struct fb_bitfield blue;
> > +                       struct fb_bitfield transp;      /* transparency
> > */ +               };
> > +               struct {                /* FOURCC-based format API    
> >  */ +                       __u32 fourcc;           /* FOURCC format    
> >    */ +                       __u32 colorspace;
> > +                       __u32 reserved[11];
> > +               } format;
> > +       };
> > +
> > +       struct fb_bitfield red;         /* bitfield in fb mem if true
> > color, */ +       struct fb_bitfield green;       /* else only length is
> > significant */ +       struct fb_bitfield blue;
> > +       struct fb_bitfield transp;      /* transparency                
> > */
> 
> These four are duplicated, cfr. the union above.

Oops :-)

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
@ 2011-08-29  8:50       ` Laurent Pinchart
  0 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-29  8:50 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Geert,

Thanks for the review.

On Monday 29 August 2011 10:13:07 Geert Uytterhoeven wrote:
> On Fri, Aug 19, 2011 at 11:37, Laurent Pinchart wrote:

[snip]

> > +- FB_TYPE_PACKED_PIXELS
> > +
> > +Color components (usually RGB or YUV) are packed together into
> > macropixels +that are stored in a single plane. The exact color
> > components layout is +described in a visual-dependent way.
> > +
> > +Frame buffer visuals that don't use multiple color components per pixel
> > +(such as monochrome and pseudo-color visuals) are reported as packed
> > frame +buffer types, even though they don't stricly speaking pack color
> > components +into macropixels.
> 
> That's because the "packing" is not about the color components, but about
> the bits that represent a single pixel.
> 
> I.e. the bits that make up the pixel (the macropixel) are stored next
> to each other
> in memory.

OK, I've modified that last sentence to read

"Frame buffer visuals that don't use multiple color components per pixel (such 
as monochrome and pseudo-color visuals) are also reported as packed frame
buffer types, as the bits that make up individual pixels are packed next to
each other in memory."

> > +- FB_TYPE_PLANES
> > +
> > +Color components are stored in separate planes. Planes are located
> > +contiguously in memory.
> 
> The bits that make up a pixel are stored in separate planes. Planes are
> located contiguously in memory.

I'm not sure to agree with this. You make it sounds like FB_TYPE_PLANES stores 
each bit in a different plane. Is that really the case ?

> - FB_TYPE_INTERLEAVED_PLANES
> 
> The bits that make up a pixel are stored in separate planes. Planes
> are interleaved.
> The interleave factor (the distance in bytes between the planes in
> memory) is stored in the type_aux field.

That's a bit unclear to me. How are they interleaved ?

> > +- FB_VISUAL_MONO01
> > +
> > +Pixels are black or white and stored on one bit. A bit set to 1
> > represents a +black pixel and a bit set to 0 a white pixel. Pixels are
> > packed together in +bytes with 8 pixels per byte.
> 
> Actually we do have drivers that use 8 bits per pixel for a monochrome
> visual. Hence:
> 
> "Pixels are black or white. A black pixel is represented by all
> (typically one) bits set to ones, a white pixel by all bits set to zeroes."

OK. I've rephrased it as

"Pixels are black or white and stored on a number of bits (typically one)
specified by the variable screen information bpp field. 

Black pixels are represented by all bits set to 1 and white pixels by all bits
set to 0. When the number of bits per pixel is smaller than 8, several pixels 
are packed together in a byte."

> > +FB_VISUAL_MONO01 is used with FB_TYPE_PACKED_PIXELS only.
> 
> ... so this may also not be true (but it is for all current drivers, IIRC).
> There's a strict orthogonality between type (how is a pixel stored in
> memory) and visual (how the bits that represent the pixel are interpreted
> and converted to a color value).

What about

"FB_VISUAL_MONO01 is currently used with FB_TYPE_PACKED_PIXELS only." ?

> Same comments for FB_VISUAL_MONO10

Fixed the same way.

> > +- FB_VISUAL_TRUECOLOR
> > +
> > +Pixels are broken into red, green and blue components, and each
> > component +indexes a read-only lookup table for the corresponding value.
> > Lookup tables +are device-dependent, and provide linear or non-linear
> > ramps.
> > +
> > +Each component is stored in memory according to the variable screen
> > +information red, green, blue and transp fields.
> 
> "Each component is stored in a macropixel according to the variable screen
> information red, green, blue and transp fields."
> 
> Storage format in memory is determined by the FB_TYPE_* value.

How so ? With FB_TYPE_PLANES and FB_VISUAL_TRUECOLOR for an RGB format, how 
are the R, G and B planes ordered ? Are color components packed or padded 
inside a plane ? I understand that the design goal was to have orthogonal 
FB_TYPE_* and FB_VISUAL_* values, but we're missing too much information for 
that to be truly generic.

> > +- FB_VISUAL_PSEUDOCOLOR and FB_VISUAL_STATIC_PSEUDOCOLOR
> > +
> > +Pixel values are encoded as indices into a colormap that stores red,
> > green and +blue components. The colormap is read-only for
> > FB_VISUAL_STATIC_PSEUDOCOLOR +and read-write for FB_VISUAL_PSEUDOCOLOR.
> > +
> > +Each pixel value is stored in the number of bits reported by the
> > variable +screen information bits_per_pixel field. Pixels are contiguous
> > in memory.
> 
> Whether pixels are contiguous in memory or not is determined by the
> FB_TYPE_* value.

How can they not be contiguous in memory ? Can you please give an example ?

> > +FB_VISUAL_PSEUDOCOLOR and FB_VISUAL_STATIC_PSEUDOCOLOR are used with
> > +FB_TYPE_PACKED_PIXELS only.
> 
> Not true. Several drivers use bit planes or interleaved bitplanes.

How does that work ?

> > +- FB_VISUAL_DIRECTCOLOR
> > +
> > +Pixels are broken into red, green and blue components, and each
> > component +indexes a programmable lookup table for the corresponding
> > value. +
> > +Each component is stored in memory according to the variable screen
> > +information red, green, blue and transp fields.
> 
> "Each component is stored in a macropixel according to the variable screen
> information red, green, blue and transp fields."
> 
> > +- FB_VISUAL_FOURCC
> > +
> > +Pixels are stored in memory as described by the format FOURCC identifier
> > +stored in the variable screen information fourcc field.
> 
> ... stored in memory and interpreted ...
> 
> > +struct fb_var_screeninfo {
> > +       __u32 xres;                     /* visible resolution          
> > */ +       __u32 yres;
> > +       __u32 xres_virtual;             /* virtual resolution          
> > */ +       __u32 yres_virtual;
> > +       __u32 xoffset;                  /* offset from virtual to visible
> > */ +       __u32 yoffset;                  /* resolution                
> >   */ +
> > +       __u32 bits_per_pixel;           /* guess what                  
> > */ +       union {
> > +               struct {                /* Legacy format API          
> >  */ +                       __u32 grayscale; /* != 0 Graylevels instead
> > of colors */ +                       /* bitfields in fb mem if true
> > color, else only */ +                       /* length is significant    
> >                    */ +                       struct fb_bitfield red;
> > +                       struct fb_bitfield green;
> > +                       struct fb_bitfield blue;
> > +                       struct fb_bitfield transp;      /* transparency
> > */ +               };
> > +               struct {                /* FOURCC-based format API    
> >  */ +                       __u32 fourcc;           /* FOURCC format    
> >    */ +                       __u32 colorspace;
> > +                       __u32 reserved[11];
> > +               } format;
> > +       };
> > +
> > +       struct fb_bitfield red;         /* bitfield in fb mem if true
> > color, */ +       struct fb_bitfield green;       /* else only length is
> > significant */ +       struct fb_bitfield blue;
> > +       struct fb_bitfield transp;      /* transparency                
> > */
> 
> These four are duplicated, cfr. the union above.

Oops :-)

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
  2011-08-29  8:50       ` Laurent Pinchart
@ 2011-08-29  9:36         ` Geert Uytterhoeven
  -1 siblings, 0 replies; 52+ messages in thread
From: Geert Uytterhoeven @ 2011-08-29  9:36 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Laurent,

On Mon, Aug 29, 2011 at 10:50, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> On Monday 29 August 2011 10:13:07 Geert Uytterhoeven wrote:
>> On Fri, Aug 19, 2011 at 11:37, Laurent Pinchart wrote:
>
> [snip]
>
>> > +- FB_TYPE_PACKED_PIXELS
>> > +
>> > +Color components (usually RGB or YUV) are packed together into
>> > macropixels +that are stored in a single plane. The exact color
>> > components layout is +described in a visual-dependent way.
>> > +
>> > +Frame buffer visuals that don't use multiple color components per pixel
>> > +(such as monochrome and pseudo-color visuals) are reported as packed
>> > frame +buffer types, even though they don't stricly speaking pack color
>> > components +into macropixels.
>>
>> That's because the "packing" is not about the color components, but about
>> the bits that represent a single pixel.
>>
>> I.e. the bits that make up the pixel (the macropixel) are stored next
>> to each other
>> in memory.
>
> OK, I've modified that last sentence to read
>
> "Frame buffer visuals that don't use multiple color components per pixel (such
> as monochrome and pseudo-color visuals) are also reported as packed frame
> buffer types, as the bits that make up individual pixels are packed next to
> each other in memory."

Still not correct, as you don't grasp the concept of e.g. bitplanes
yet (see below).
The visual doesn't have anything to do with how the macropixels are stored in
memory.

>> > +- FB_TYPE_PLANES
>> > +
>> > +Color components are stored in separate planes. Planes are located
>> > +contiguously in memory.
>>
>> The bits that make up a pixel are stored in separate planes. Planes are
>> located contiguously in memory.
>
> I'm not sure to agree with this. You make it sounds like FB_TYPE_PLANES stores
> each bit in a different plane. Is that really the case ?

Yes.

First you store all "first" (fbdev does lack a way to specify little
or big endian here)
bits of each pixel in memory, contiguously. Then the second bit of
each pixel, and so on.

For 8 pixels (A - H) with 4 bits per pixel (0 - 3) (i.e. the first pixel is
[A0 A1 A2 A3]), that would be like:

A0 B0 C0 D0 E0 F0 G0 H0 A1 B1 C1 D1 E1 F1 G1 H1 A2 B2 C2 D2 E2 F2 G2 H2
A3 B3 C3 D3 E3 F3 G3 H3

http://en.wikipedia.org/wiki/Bit_plane
http://en.wikipedia.org/wiki/Planar_(computer_graphics)
http://en.wikipedia.org/wiki/Color_depth

>> - FB_TYPE_INTERLEAVED_PLANES
>>
>> The bits that make up a pixel are stored in separate planes. Planes
>> are interleaved.
>> The interleave factor (the distance in bytes between the planes in
>> memory) is stored in the type_aux field.
>
> That's a bit unclear to me. How are they interleaved ?

Instead of storing the same bits of all pixels contiguously into memory, they
are interleaved. Typically this is done per line (type_aux is the
length of a line in bytes),
or per word (Atari uses 2 bytes interleaving.

E.g. for a 320 x 200 display, with FB_TYPE_PLANES, you would store 320 x 200 =
64000 first bits, followed 64000 second bits, and so on.

With FB_TYPE_INTERLEAVED_PLANES and type_aux = 320 / 8 = 40,
you store the first line of the screen as 320 first bits, followed by
320 second bits, and so on.
Then the next line, as 320 first bits, followed by 320 second bits, and so on...

Hence the bits that make up a pixel are spread across memory. It was
useful in the days
computers couldn't show many colors, and allows things like 5 or 6
bits per pixels.

>> > +- FB_VISUAL_MONO01
>> > +
>> > +Pixels are black or white and stored on one bit. A bit set to 1
>> > represents a +black pixel and a bit set to 0 a white pixel. Pixels are
>> > packed together in +bytes with 8 pixels per byte.
>>
>> Actually we do have drivers that use 8 bits per pixel for a monochrome
>> visual. Hence:
>>
>> "Pixels are black or white. A black pixel is represented by all
>> (typically one) bits set to ones, a white pixel by all bits set to zeroes."
>
> OK. I've rephrased it as
>
> "Pixels are black or white and stored on a number of bits (typically one)
> specified by the variable screen information bpp field.
>
> Black pixels are represented by all bits set to 1 and white pixels by all bits
> set to 0. When the number of bits per pixel is smaller than 8, several pixels
> are packed together in a byte."

OK.

>> > +FB_VISUAL_MONO01 is used with FB_TYPE_PACKED_PIXELS only.
>>
>> ... so this may also not be true (but it is for all current drivers, IIRC).
>> There's a strict orthogonality between type (how is a pixel stored in
>> memory) and visual (how the bits that represent the pixel are interpreted
>> and converted to a color value).
>
> What about
>
> "FB_VISUAL_MONO01 is currently used with FB_TYPE_PACKED_PIXELS only." ?

stifb.c seems to use FB_TYPE_PLANES, but it uses bits_per_pixel is 1, so
FB_TYPE_PACKED_PIXELS, FB_TYPE_PLANES, and FB_TYPE_INTERLEAVED_PLANES
all degenerate to the same case anyway.

>> > +- FB_VISUAL_TRUECOLOR
>> > +
>> > +Pixels are broken into red, green and blue components, and each
>> > component +indexes a read-only lookup table for the corresponding value.
>> > Lookup tables +are device-dependent, and provide linear or non-linear
>> > ramps.
>> > +
>> > +Each component is stored in memory according to the variable screen
>> > +information red, green, blue and transp fields.
>>
>> "Each component is stored in a macropixel according to the variable screen
>> information red, green, blue and transp fields."
>>
>> Storage format in memory is determined by the FB_TYPE_* value.
>
> How so ? With FB_TYPE_PLANES and FB_VISUAL_TRUECOLOR for an RGB format, how
> are the R, G and B planes ordered ? Are color components packed or padded

That's specified by the fb_bitfield structs.

> inside a plane ? I understand that the design goal was to have orthogonal
> FB_TYPE_* and FB_VISUAL_* values, but we're missing too much information for
> that to be truly generic.

The visual specifies how to interprete the fields that make up a pixel (as color
components, indices, ...).
The fb_bitfield structs specify how the fields are laid out in a pixel of size
bits_per_pixel.
The frame buffer type specifies how pixels are laid out in memory.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
@ 2011-08-29  9:36         ` Geert Uytterhoeven
  0 siblings, 0 replies; 52+ messages in thread
From: Geert Uytterhoeven @ 2011-08-29  9:36 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Laurent,

On Mon, Aug 29, 2011 at 10:50, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> On Monday 29 August 2011 10:13:07 Geert Uytterhoeven wrote:
>> On Fri, Aug 19, 2011 at 11:37, Laurent Pinchart wrote:
>
> [snip]
>
>> > +- FB_TYPE_PACKED_PIXELS
>> > +
>> > +Color components (usually RGB or YUV) are packed together into
>> > macropixels +that are stored in a single plane. The exact color
>> > components layout is +described in a visual-dependent way.
>> > +
>> > +Frame buffer visuals that don't use multiple color components per pixel
>> > +(such as monochrome and pseudo-color visuals) are reported as packed
>> > frame +buffer types, even though they don't stricly speaking pack color
>> > components +into macropixels.
>>
>> That's because the "packing" is not about the color components, but about
>> the bits that represent a single pixel.
>>
>> I.e. the bits that make up the pixel (the macropixel) are stored next
>> to each other
>> in memory.
>
> OK, I've modified that last sentence to read
>
> "Frame buffer visuals that don't use multiple color components per pixel (such
> as monochrome and pseudo-color visuals) are also reported as packed frame
> buffer types, as the bits that make up individual pixels are packed next to
> each other in memory."

Still not correct, as you don't grasp the concept of e.g. bitplanes
yet (see below).
The visual doesn't have anything to do with how the macropixels are stored in
memory.

>> > +- FB_TYPE_PLANES
>> > +
>> > +Color components are stored in separate planes. Planes are located
>> > +contiguously in memory.
>>
>> The bits that make up a pixel are stored in separate planes. Planes are
>> located contiguously in memory.
>
> I'm not sure to agree with this. You make it sounds like FB_TYPE_PLANES stores
> each bit in a different plane. Is that really the case ?

Yes.

First you store all "first" (fbdev does lack a way to specify little
or big endian here)
bits of each pixel in memory, contiguously. Then the second bit of
each pixel, and so on.

For 8 pixels (A - H) with 4 bits per pixel (0 - 3) (i.e. the first pixel is
[A0 A1 A2 A3]), that would be like:

A0 B0 C0 D0 E0 F0 G0 H0 A1 B1 C1 D1 E1 F1 G1 H1 A2 B2 C2 D2 E2 F2 G2 H2
A3 B3 C3 D3 E3 F3 G3 H3

http://en.wikipedia.org/wiki/Bit_plane
http://en.wikipedia.org/wiki/Planar_(computer_graphics)
http://en.wikipedia.org/wiki/Color_depth

>> - FB_TYPE_INTERLEAVED_PLANES
>>
>> The bits that make up a pixel are stored in separate planes. Planes
>> are interleaved.
>> The interleave factor (the distance in bytes between the planes in
>> memory) is stored in the type_aux field.
>
> That's a bit unclear to me. How are they interleaved ?

Instead of storing the same bits of all pixels contiguously into memory, they
are interleaved. Typically this is done per line (type_aux is the
length of a line in bytes),
or per word (Atari uses 2 bytes interleaving.

E.g. for a 320 x 200 display, with FB_TYPE_PLANES, you would store 320 x 200 64000 first bits, followed 64000 second bits, and so on.

With FB_TYPE_INTERLEAVED_PLANES and type_aux = 320 / 8 = 40,
you store the first line of the screen as 320 first bits, followed by
320 second bits, and so on.
Then the next line, as 320 first bits, followed by 320 second bits, and so on...

Hence the bits that make up a pixel are spread across memory. It was
useful in the days
computers couldn't show many colors, and allows things like 5 or 6
bits per pixels.

>> > +- FB_VISUAL_MONO01
>> > +
>> > +Pixels are black or white and stored on one bit. A bit set to 1
>> > represents a +black pixel and a bit set to 0 a white pixel. Pixels are
>> > packed together in +bytes with 8 pixels per byte.
>>
>> Actually we do have drivers that use 8 bits per pixel for a monochrome
>> visual. Hence:
>>
>> "Pixels are black or white. A black pixel is represented by all
>> (typically one) bits set to ones, a white pixel by all bits set to zeroes."
>
> OK. I've rephrased it as
>
> "Pixels are black or white and stored on a number of bits (typically one)
> specified by the variable screen information bpp field.
>
> Black pixels are represented by all bits set to 1 and white pixels by all bits
> set to 0. When the number of bits per pixel is smaller than 8, several pixels
> are packed together in a byte."

OK.

>> > +FB_VISUAL_MONO01 is used with FB_TYPE_PACKED_PIXELS only.
>>
>> ... so this may also not be true (but it is for all current drivers, IIRC).
>> There's a strict orthogonality between type (how is a pixel stored in
>> memory) and visual (how the bits that represent the pixel are interpreted
>> and converted to a color value).
>
> What about
>
> "FB_VISUAL_MONO01 is currently used with FB_TYPE_PACKED_PIXELS only." ?

stifb.c seems to use FB_TYPE_PLANES, but it uses bits_per_pixel is 1, so
FB_TYPE_PACKED_PIXELS, FB_TYPE_PLANES, and FB_TYPE_INTERLEAVED_PLANES
all degenerate to the same case anyway.

>> > +- FB_VISUAL_TRUECOLOR
>> > +
>> > +Pixels are broken into red, green and blue components, and each
>> > component +indexes a read-only lookup table for the corresponding value.
>> > Lookup tables +are device-dependent, and provide linear or non-linear
>> > ramps.
>> > +
>> > +Each component is stored in memory according to the variable screen
>> > +information red, green, blue and transp fields.
>>
>> "Each component is stored in a macropixel according to the variable screen
>> information red, green, blue and transp fields."
>>
>> Storage format in memory is determined by the FB_TYPE_* value.
>
> How so ? With FB_TYPE_PLANES and FB_VISUAL_TRUECOLOR for an RGB format, how
> are the R, G and B planes ordered ? Are color components packed or padded

That's specified by the fb_bitfield structs.

> inside a plane ? I understand that the design goal was to have orthogonal
> FB_TYPE_* and FB_VISUAL_* values, but we're missing too much information for
> that to be truly generic.

The visual specifies how to interprete the fields that make up a pixel (as color
components, indices, ...).
The fb_bitfield structs specify how the fields are laid out in a pixel of size
bits_per_pixel.
The frame buffer type specifies how pixels are laid out in memory.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
  2011-08-29  9:36         ` Geert Uytterhoeven
@ 2011-08-29 10:09           ` Laurent Pinchart
  -1 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-29 10:09 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Geert,

On Monday 29 August 2011 11:36:07 Geert Uytterhoeven wrote:
> On Mon, Aug 29, 2011 at 10:50, Laurent Pinchart wrote:
> > On Monday 29 August 2011 10:13:07 Geert Uytterhoeven wrote:
> >> On Fri, Aug 19, 2011 at 11:37, Laurent Pinchart wrote:
> > [snip]
> > 
> >> > +- FB_TYPE_PACKED_PIXELS
> >> > +
> >> > +Color components (usually RGB or YUV) are packed together into
> >> > macropixels +that are stored in a single plane. The exact color
> >> > components layout is +described in a visual-dependent way.
> >> > +
> >> > +Frame buffer visuals that don't use multiple color components per
> >> > pixel +(such as monochrome and pseudo-color visuals) are reported as
> >> > packed frame +buffer types, even though they don't stricly speaking
> >> > pack color components +into macropixels.
> >> 
> >> That's because the "packing" is not about the color components, but
> >> about the bits that represent a single pixel.
> >> 
> >> I.e. the bits that make up the pixel (the macropixel) are stored next
> >> to each other
> >> in memory.
> > 
> > OK, I've modified that last sentence to read
> > 
> > "Frame buffer visuals that don't use multiple color components per pixel
> > (such as monochrome and pseudo-color visuals) are also reported as
> > packed frame buffer types, as the bits that make up individual pixels
> > are packed next to each other in memory."
> 
> Still not correct, as you don't grasp the concept of e.g. bitplanes
> yet (see below).
> The visual doesn't have anything to do with how the macropixels are stored
> in memory.
> 
> >> > +- FB_TYPE_PLANES
> >> > +
> >> > +Color components are stored in separate planes. Planes are located
> >> > +contiguously in memory.
> >> 
> >> The bits that make up a pixel are stored in separate planes. Planes are
> >> located contiguously in memory.
> > 
> > I'm not sure to agree with this. You make it sounds like FB_TYPE_PLANES
> > stores each bit in a different plane. Is that really the case ?
> 
> Yes.
>
> First you store all "first" (fbdev does lack a way to specify little
> or big endian here)
> bits of each pixel in memory, contiguously. Then the second bit of
> each pixel, and so on.
> 
> For 8 pixels (A - H) with 4 bits per pixel (0 - 3) (i.e. the first pixel is
> [A0 A1 A2 A3]), that would be like:
> 
> A0 B0 C0 D0 E0 F0 G0 H0 A1 B1 C1 D1 E1 F1 G1 H1 A2 B2 C2 D2 E2 F2 G2 H2
> A3 B3 C3 D3 E3 F3 G3 H3
> 
> http://en.wikipedia.org/wiki/Bit_plane
> http://en.wikipedia.org/wiki/Planar_(computer_graphics)
> http://en.wikipedia.org/wiki/Color_depth

Thank you. That's clearer now. Planar formats in V4L2 are different, hence my 
initial confusion.

If my understanding is now correct, a V4L2 planar YUV type where Y, U and V 
components are stored in separate byte-oriented planes, with each plane 
storing Y, U or V components packed (such as http://linuxtv.org/downloads/v4l-
dvb-apis/V4L2-PIX-FMT-YUV422P.html), would be of neither FB_TYPE_PLANES nor 
FB_TYPE_PACKED. The same would be true for an RGB format where each component 
is stored in a separate plane with each plane sotring R, G or B packed.

If the above is correct, what FB_TYPE_* should a driver report when using 
FB_VISUAL_FOURCC with V4L2_PIX_FMT_YUV422P (http://linuxtv.org/downloads/v4l-
dvb-apis/V4L2-PIX-FMT-YUV422P.html) or V4L2_PIX_FMT_NV12 
(http://linuxtv.org/downloads/v4l-dvb-apis/re25.html) for instance ?

> >> - FB_TYPE_INTERLEAVED_PLANES
> >> 
> >> The bits that make up a pixel are stored in separate planes. Planes
> >> are interleaved.
> >> The interleave factor (the distance in bytes between the planes in
> >> memory) is stored in the type_aux field.
> > 
> > That's a bit unclear to me. How are they interleaved ?
> 
> Instead of storing the same bits of all pixels contiguously into memory,
> they are interleaved. Typically this is done per line (type_aux is the
> length of a line in bytes),
> or per word (Atari uses 2 bytes interleaving.
> 
> E.g. for a 320 x 200 display, with FB_TYPE_PLANES, you would store 320 x
> 200 = 64000 first bits, followed 64000 second bits, and so on.
> 
> With FB_TYPE_INTERLEAVED_PLANES and type_aux = 320 / 8 = 40,
> you store the first line of the screen as 320 first bits, followed by
> 320 second bits, and so on.
> Then the next line, as 320 first bits, followed by 320 second bits, and so
> on...
> 
> Hence the bits that make up a pixel are spread across memory. It was
> useful in the days
> computers couldn't show many colors, and allows things like 5 or 6
> bits per pixels.
> 
> >> > +- FB_VISUAL_MONO01
> >> > +
> >> > +Pixels are black or white and stored on one bit. A bit set to 1
> >> > represents a +black pixel and a bit set to 0 a white pixel. Pixels are
> >> > packed together in +bytes with 8 pixels per byte.
> >> 
> >> Actually we do have drivers that use 8 bits per pixel for a monochrome
> >> visual. Hence:
> >> 
> >> "Pixels are black or white. A black pixel is represented by all
> >> (typically one) bits set to ones, a white pixel by all bits set to
> >> zeroes."
> > 
> > OK. I've rephrased it as
> > 
> > "Pixels are black or white and stored on a number of bits (typically one)
> > specified by the variable screen information bpp field.
> > 
> > Black pixels are represented by all bits set to 1 and white pixels by all
> > bits set to 0. When the number of bits per pixel is smaller than 8,
> > several pixels are packed together in a byte."
> 
> OK.
> 
> >> > +FB_VISUAL_MONO01 is used with FB_TYPE_PACKED_PIXELS only.
> >> 
> >> ... so this may also not be true (but it is for all current drivers,
> >> IIRC). There's a strict orthogonality between type (how is a pixel
> >> stored in memory) and visual (how the bits that represent the pixel are
> >> interpreted and converted to a color value).
> > 
> > What about
> > 
> > "FB_VISUAL_MONO01 is currently used with FB_TYPE_PACKED_PIXELS only." ?
> 
> stifb.c seems to use FB_TYPE_PLANES, but it uses bits_per_pixel is 1, so
> FB_TYPE_PACKED_PIXELS, FB_TYPE_PLANES, and FB_TYPE_INTERLEAVED_PLANES
> all degenerate to the same case anyway.
> 
> >> > +- FB_VISUAL_TRUECOLOR
> >> > +
> >> > +Pixels are broken into red, green and blue components, and each
> >> > component +indexes a read-only lookup table for the corresponding
> >> > value. Lookup tables +are device-dependent, and provide linear or
> >> > non-linear ramps.
> >> > +
> >> > +Each component is stored in memory according to the variable screen
> >> > +information red, green, blue and transp fields.
> >> 
> >> "Each component is stored in a macropixel according to the variable
> >> screen information red, green, blue and transp fields."
> >> 
> >> Storage format in memory is determined by the FB_TYPE_* value.
> > 
> > How so ? With FB_TYPE_PLANES and FB_VISUAL_TRUECOLOR for an RGB format,
> > how are the R, G and B planes ordered ? Are color components packed or
> > padded
> 
> That's specified by the fb_bitfield structs.
> 
> > inside a plane ? I understand that the design goal was to have orthogonal
> > FB_TYPE_* and FB_VISUAL_* values, but we're missing too much information
> > for that to be truly generic.
> 
> The visual specifies how to interprete the fields that make up a pixel (as
> color components, indices, ...).
> The fb_bitfield structs specify how the fields are laid out in a pixel of
> size bits_per_pixel.
> The frame buffer type specifies how pixels are laid out in memory.

That's fine if the FB device uses bitplanes, but not if it uses a format such 
as the ones described above.

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
@ 2011-08-29 10:09           ` Laurent Pinchart
  0 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-29 10:09 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Geert,

On Monday 29 August 2011 11:36:07 Geert Uytterhoeven wrote:
> On Mon, Aug 29, 2011 at 10:50, Laurent Pinchart wrote:
> > On Monday 29 August 2011 10:13:07 Geert Uytterhoeven wrote:
> >> On Fri, Aug 19, 2011 at 11:37, Laurent Pinchart wrote:
> > [snip]
> > 
> >> > +- FB_TYPE_PACKED_PIXELS
> >> > +
> >> > +Color components (usually RGB or YUV) are packed together into
> >> > macropixels +that are stored in a single plane. The exact color
> >> > components layout is +described in a visual-dependent way.
> >> > +
> >> > +Frame buffer visuals that don't use multiple color components per
> >> > pixel +(such as monochrome and pseudo-color visuals) are reported as
> >> > packed frame +buffer types, even though they don't stricly speaking
> >> > pack color components +into macropixels.
> >> 
> >> That's because the "packing" is not about the color components, but
> >> about the bits that represent a single pixel.
> >> 
> >> I.e. the bits that make up the pixel (the macropixel) are stored next
> >> to each other
> >> in memory.
> > 
> > OK, I've modified that last sentence to read
> > 
> > "Frame buffer visuals that don't use multiple color components per pixel
> > (such as monochrome and pseudo-color visuals) are also reported as
> > packed frame buffer types, as the bits that make up individual pixels
> > are packed next to each other in memory."
> 
> Still not correct, as you don't grasp the concept of e.g. bitplanes
> yet (see below).
> The visual doesn't have anything to do with how the macropixels are stored
> in memory.
> 
> >> > +- FB_TYPE_PLANES
> >> > +
> >> > +Color components are stored in separate planes. Planes are located
> >> > +contiguously in memory.
> >> 
> >> The bits that make up a pixel are stored in separate planes. Planes are
> >> located contiguously in memory.
> > 
> > I'm not sure to agree with this. You make it sounds like FB_TYPE_PLANES
> > stores each bit in a different plane. Is that really the case ?
> 
> Yes.
>
> First you store all "first" (fbdev does lack a way to specify little
> or big endian here)
> bits of each pixel in memory, contiguously. Then the second bit of
> each pixel, and so on.
> 
> For 8 pixels (A - H) with 4 bits per pixel (0 - 3) (i.e. the first pixel is
> [A0 A1 A2 A3]), that would be like:
> 
> A0 B0 C0 D0 E0 F0 G0 H0 A1 B1 C1 D1 E1 F1 G1 H1 A2 B2 C2 D2 E2 F2 G2 H2
> A3 B3 C3 D3 E3 F3 G3 H3
> 
> http://en.wikipedia.org/wiki/Bit_plane
> http://en.wikipedia.org/wiki/Planar_(computer_graphics)
> http://en.wikipedia.org/wiki/Color_depth

Thank you. That's clearer now. Planar formats in V4L2 are different, hence my 
initial confusion.

If my understanding is now correct, a V4L2 planar YUV type where Y, U and V 
components are stored in separate byte-oriented planes, with each plane 
storing Y, U or V components packed (such as http://linuxtv.org/downloads/v4l-
dvb-apis/V4L2-PIX-FMT-YUV422P.html), would be of neither FB_TYPE_PLANES nor 
FB_TYPE_PACKED. The same would be true for an RGB format where each component 
is stored in a separate plane with each plane sotring R, G or B packed.

If the above is correct, what FB_TYPE_* should a driver report when using 
FB_VISUAL_FOURCC with V4L2_PIX_FMT_YUV422P (http://linuxtv.org/downloads/v4l-
dvb-apis/V4L2-PIX-FMT-YUV422P.html) or V4L2_PIX_FMT_NV12 
(http://linuxtv.org/downloads/v4l-dvb-apis/re25.html) for instance ?

> >> - FB_TYPE_INTERLEAVED_PLANES
> >> 
> >> The bits that make up a pixel are stored in separate planes. Planes
> >> are interleaved.
> >> The interleave factor (the distance in bytes between the planes in
> >> memory) is stored in the type_aux field.
> > 
> > That's a bit unclear to me. How are they interleaved ?
> 
> Instead of storing the same bits of all pixels contiguously into memory,
> they are interleaved. Typically this is done per line (type_aux is the
> length of a line in bytes),
> or per word (Atari uses 2 bytes interleaving.
> 
> E.g. for a 320 x 200 display, with FB_TYPE_PLANES, you would store 320 x
> 200 = 64000 first bits, followed 64000 second bits, and so on.
> 
> With FB_TYPE_INTERLEAVED_PLANES and type_aux = 320 / 8 = 40,
> you store the first line of the screen as 320 first bits, followed by
> 320 second bits, and so on.
> Then the next line, as 320 first bits, followed by 320 second bits, and so
> on...
> 
> Hence the bits that make up a pixel are spread across memory. It was
> useful in the days
> computers couldn't show many colors, and allows things like 5 or 6
> bits per pixels.
> 
> >> > +- FB_VISUAL_MONO01
> >> > +
> >> > +Pixels are black or white and stored on one bit. A bit set to 1
> >> > represents a +black pixel and a bit set to 0 a white pixel. Pixels are
> >> > packed together in +bytes with 8 pixels per byte.
> >> 
> >> Actually we do have drivers that use 8 bits per pixel for a monochrome
> >> visual. Hence:
> >> 
> >> "Pixels are black or white. A black pixel is represented by all
> >> (typically one) bits set to ones, a white pixel by all bits set to
> >> zeroes."
> > 
> > OK. I've rephrased it as
> > 
> > "Pixels are black or white and stored on a number of bits (typically one)
> > specified by the variable screen information bpp field.
> > 
> > Black pixels are represented by all bits set to 1 and white pixels by all
> > bits set to 0. When the number of bits per pixel is smaller than 8,
> > several pixels are packed together in a byte."
> 
> OK.
> 
> >> > +FB_VISUAL_MONO01 is used with FB_TYPE_PACKED_PIXELS only.
> >> 
> >> ... so this may also not be true (but it is for all current drivers,
> >> IIRC). There's a strict orthogonality between type (how is a pixel
> >> stored in memory) and visual (how the bits that represent the pixel are
> >> interpreted and converted to a color value).
> > 
> > What about
> > 
> > "FB_VISUAL_MONO01 is currently used with FB_TYPE_PACKED_PIXELS only." ?
> 
> stifb.c seems to use FB_TYPE_PLANES, but it uses bits_per_pixel is 1, so
> FB_TYPE_PACKED_PIXELS, FB_TYPE_PLANES, and FB_TYPE_INTERLEAVED_PLANES
> all degenerate to the same case anyway.
> 
> >> > +- FB_VISUAL_TRUECOLOR
> >> > +
> >> > +Pixels are broken into red, green and blue components, and each
> >> > component +indexes a read-only lookup table for the corresponding
> >> > value. Lookup tables +are device-dependent, and provide linear or
> >> > non-linear ramps.
> >> > +
> >> > +Each component is stored in memory according to the variable screen
> >> > +information red, green, blue and transp fields.
> >> 
> >> "Each component is stored in a macropixel according to the variable
> >> screen information red, green, blue and transp fields."
> >> 
> >> Storage format in memory is determined by the FB_TYPE_* value.
> > 
> > How so ? With FB_TYPE_PLANES and FB_VISUAL_TRUECOLOR for an RGB format,
> > how are the R, G and B planes ordered ? Are color components packed or
> > padded
> 
> That's specified by the fb_bitfield structs.
> 
> > inside a plane ? I understand that the design goal was to have orthogonal
> > FB_TYPE_* and FB_VISUAL_* values, but we're missing too much information
> > for that to be truly generic.
> 
> The visual specifies how to interprete the fields that make up a pixel (as
> color components, indices, ...).
> The fb_bitfield structs specify how the fields are laid out in a pixel of
> size bits_per_pixel.
> The frame buffer type specifies how pixels are laid out in memory.

That's fine if the FB device uses bitplanes, but not if it uses a format such 
as the ones described above.

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
  2011-08-29 10:09           ` Laurent Pinchart
@ 2011-08-29 11:04             ` Geert Uytterhoeven
  -1 siblings, 0 replies; 52+ messages in thread
From: Geert Uytterhoeven @ 2011-08-29 11:04 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Laurent,

On Mon, Aug 29, 2011 at 12:09, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> On Monday 29 August 2011 11:36:07 Geert Uytterhoeven wrote:
>> On Mon, Aug 29, 2011 at 10:50, Laurent Pinchart wrote:

[...]

> If my understanding is now correct, a V4L2 planar YUV type where Y, U and V
> components are stored in separate byte-oriented planes, with each plane
> storing Y, U or V components packed (such as http://linuxtv.org/downloads/v4l-
> dvb-apis/V4L2-PIX-FMT-YUV422P.html), would be of neither FB_TYPE_PLANES nor
> FB_TYPE_PACKED. The same would be true for an RGB format where each component
> is stored in a separate plane with each plane sotring R, G or B packed.

Indeed. Currently this cannot be represented.
For ideas from the past, see e.g.
http://comments.gmane.org/gmane.linux.fbdev.devel/10951.

> If the above is correct, what FB_TYPE_* should a driver report when using
> FB_VISUAL_FOURCC with V4L2_PIX_FMT_YUV422P (http://linuxtv.org/downloads/v4l-
> dvb-apis/V4L2-PIX-FMT-YUV422P.html) or V4L2_PIX_FMT_NV12
> (http://linuxtv.org/downloads/v4l-dvb-apis/re25.html) for instance ?

We need new types for those. Or always use FOURCC for them.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
@ 2011-08-29 11:04             ` Geert Uytterhoeven
  0 siblings, 0 replies; 52+ messages in thread
From: Geert Uytterhoeven @ 2011-08-29 11:04 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Laurent,

On Mon, Aug 29, 2011 at 12:09, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> On Monday 29 August 2011 11:36:07 Geert Uytterhoeven wrote:
>> On Mon, Aug 29, 2011 at 10:50, Laurent Pinchart wrote:

[...]

> If my understanding is now correct, a V4L2 planar YUV type where Y, U and V
> components are stored in separate byte-oriented planes, with each plane
> storing Y, U or V components packed (such as http://linuxtv.org/downloads/v4l-
> dvb-apis/V4L2-PIX-FMT-YUV422P.html), would be of neither FB_TYPE_PLANES nor
> FB_TYPE_PACKED. The same would be true for an RGB format where each component
> is stored in a separate plane with each plane sotring R, G or B packed.

Indeed. Currently this cannot be represented.
For ideas from the past, see e.g.
http://comments.gmane.org/gmane.linux.fbdev.devel/10951.

> If the above is correct, what FB_TYPE_* should a driver report when using
> FB_VISUAL_FOURCC with V4L2_PIX_FMT_YUV422P (http://linuxtv.org/downloads/v4l-
> dvb-apis/V4L2-PIX-FMT-YUV422P.html) or V4L2_PIX_FMT_NV12
> (http://linuxtv.org/downloads/v4l-dvb-apis/re25.html) for instance ?

We need new types for those. Or always use FOURCC for them.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
  2011-08-29 11:04             ` Geert Uytterhoeven
@ 2011-08-29 11:08               ` Laurent Pinchart
  -1 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-29 11:08 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Geert,

On Monday 29 August 2011 13:04:15 Geert Uytterhoeven wrote:
> On Mon, Aug 29, 2011 at 12:09, Laurent Pinchart wrote:
> > On Monday 29 August 2011 11:36:07 Geert Uytterhoeven wrote:
> >> On Mon, Aug 29, 2011 at 10:50, Laurent Pinchart wrote:
> [...]
> 
> > If my understanding is now correct, a V4L2 planar YUV type where Y, U and
> > V components are stored in separate byte-oriented planes, with each
> > plane storing Y, U or V components packed (such as
> > http://linuxtv.org/downloads/v4l- dvb-apis/V4L2-PIX-FMT-YUV422P.html),
> > would be of neither FB_TYPE_PLANES nor FB_TYPE_PACKED. The same would be
> > true for an RGB format where each component is stored in a separate
> > plane with each plane sotring R, G or B packed.
> 
> Indeed. Currently this cannot be represented.

Good, at least I now understand the situation :-)

> For ideas from the past, see e.g.
> http://comments.gmane.org/gmane.linux.fbdev.devel/10951.
> 
> > If the above is correct, what FB_TYPE_* should a driver report when using
> > FB_VISUAL_FOURCC with V4L2_PIX_FMT_YUV422P
> > (http://linuxtv.org/downloads/v4l- dvb-apis/V4L2-PIX-FMT-YUV422P.html)
> > or V4L2_PIX_FMT_NV12
> > (http://linuxtv.org/downloads/v4l-dvb-apis/re25.html) for instance ?
> 
> We need new types for those. Or always use FOURCC for them.

My proposal currently defined FB_VISUAL_FOURCC. What about adding 
FB_TYPE_FOURCC as well ?

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
@ 2011-08-29 11:08               ` Laurent Pinchart
  0 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-29 11:08 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Geert,

On Monday 29 August 2011 13:04:15 Geert Uytterhoeven wrote:
> On Mon, Aug 29, 2011 at 12:09, Laurent Pinchart wrote:
> > On Monday 29 August 2011 11:36:07 Geert Uytterhoeven wrote:
> >> On Mon, Aug 29, 2011 at 10:50, Laurent Pinchart wrote:
> [...]
> 
> > If my understanding is now correct, a V4L2 planar YUV type where Y, U and
> > V components are stored in separate byte-oriented planes, with each
> > plane storing Y, U or V components packed (such as
> > http://linuxtv.org/downloads/v4l- dvb-apis/V4L2-PIX-FMT-YUV422P.html),
> > would be of neither FB_TYPE_PLANES nor FB_TYPE_PACKED. The same would be
> > true for an RGB format where each component is stored in a separate
> > plane with each plane sotring R, G or B packed.
> 
> Indeed. Currently this cannot be represented.

Good, at least I now understand the situation :-)

> For ideas from the past, see e.g.
> http://comments.gmane.org/gmane.linux.fbdev.devel/10951.
> 
> > If the above is correct, what FB_TYPE_* should a driver report when using
> > FB_VISUAL_FOURCC with V4L2_PIX_FMT_YUV422P
> > (http://linuxtv.org/downloads/v4l- dvb-apis/V4L2-PIX-FMT-YUV422P.html)
> > or V4L2_PIX_FMT_NV12
> > (http://linuxtv.org/downloads/v4l-dvb-apis/re25.html) for instance ?
> 
> We need new types for those. Or always use FOURCC for them.

My proposal currently defined FB_VISUAL_FOURCC. What about adding 
FB_TYPE_FOURCC as well ?

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
  2011-08-29 11:08               ` Laurent Pinchart
@ 2011-08-29 11:20                 ` Geert Uytterhoeven
  -1 siblings, 0 replies; 52+ messages in thread
From: Geert Uytterhoeven @ 2011-08-29 11:20 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-fbdev, linux-media, magnus.damm

On Mon, Aug 29, 2011 at 13:08, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> On Monday 29 August 2011 13:04:15 Geert Uytterhoeven wrote:
>> On Mon, Aug 29, 2011 at 12:09, Laurent Pinchart wrote:
>> > On Monday 29 August 2011 11:36:07 Geert Uytterhoeven wrote:
>> >> On Mon, Aug 29, 2011 at 10:50, Laurent Pinchart wrote:
>> [...]
>>
>> > If my understanding is now correct, a V4L2 planar YUV type where Y, U and
>> > V components are stored in separate byte-oriented planes, with each
>> > plane storing Y, U or V components packed (such as
>> > http://linuxtv.org/downloads/v4l- dvb-apis/V4L2-PIX-FMT-YUV422P.html),
>> > would be of neither FB_TYPE_PLANES nor FB_TYPE_PACKED. The same would be
>> > true for an RGB format where each component is stored in a separate
>> > plane with each plane sotring R, G or B packed.
>>
>> Indeed. Currently this cannot be represented.
>
> Good, at least I now understand the situation :-)
>
>> For ideas from the past, see e.g.
>> http://comments.gmane.org/gmane.linux.fbdev.devel/10951.
>>
>> > If the above is correct, what FB_TYPE_* should a driver report when using
>> > FB_VISUAL_FOURCC with V4L2_PIX_FMT_YUV422P
>> > (http://linuxtv.org/downloads/v4l- dvb-apis/V4L2-PIX-FMT-YUV422P.html)
>> > or V4L2_PIX_FMT_NV12
>> > (http://linuxtv.org/downloads/v4l-dvb-apis/re25.html) for instance ?
>>
>> We need new types for those. Or always use FOURCC for them.
>
> My proposal currently defined FB_VISUAL_FOURCC. What about adding
> FB_TYPE_FOURCC as well ?

That may make sense.
When will the driver report FB_{TYPE,VISUAL}_FOURCC?
  - When using a mode that cannot be represented in the legacy way,
  - But what with modes that can be represented? Legacy software cannot
    handle FB_{TYPE,VISUAL}_FOURCC.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
@ 2011-08-29 11:20                 ` Geert Uytterhoeven
  0 siblings, 0 replies; 52+ messages in thread
From: Geert Uytterhoeven @ 2011-08-29 11:20 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-fbdev, linux-media, magnus.damm

On Mon, Aug 29, 2011 at 13:08, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> On Monday 29 August 2011 13:04:15 Geert Uytterhoeven wrote:
>> On Mon, Aug 29, 2011 at 12:09, Laurent Pinchart wrote:
>> > On Monday 29 August 2011 11:36:07 Geert Uytterhoeven wrote:
>> >> On Mon, Aug 29, 2011 at 10:50, Laurent Pinchart wrote:
>> [...]
>>
>> > If my understanding is now correct, a V4L2 planar YUV type where Y, U and
>> > V components are stored in separate byte-oriented planes, with each
>> > plane storing Y, U or V components packed (such as
>> > http://linuxtv.org/downloads/v4l- dvb-apis/V4L2-PIX-FMT-YUV422P.html),
>> > would be of neither FB_TYPE_PLANES nor FB_TYPE_PACKED. The same would be
>> > true for an RGB format where each component is stored in a separate
>> > plane with each plane sotring R, G or B packed.
>>
>> Indeed. Currently this cannot be represented.
>
> Good, at least I now understand the situation :-)
>
>> For ideas from the past, see e.g.
>> http://comments.gmane.org/gmane.linux.fbdev.devel/10951.
>>
>> > If the above is correct, what FB_TYPE_* should a driver report when using
>> > FB_VISUAL_FOURCC with V4L2_PIX_FMT_YUV422P
>> > (http://linuxtv.org/downloads/v4l- dvb-apis/V4L2-PIX-FMT-YUV422P.html)
>> > or V4L2_PIX_FMT_NV12
>> > (http://linuxtv.org/downloads/v4l-dvb-apis/re25.html) for instance ?
>>
>> We need new types for those. Or always use FOURCC for them.
>
> My proposal currently defined FB_VISUAL_FOURCC. What about adding
> FB_TYPE_FOURCC as well ?

That may make sense.
When will the driver report FB_{TYPE,VISUAL}_FOURCC?
  - When using a mode that cannot be represented in the legacy way,
  - But what with modes that can be represented? Legacy software cannot
    handle FB_{TYPE,VISUAL}_FOURCC.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
  2011-08-29 11:20                 ` Geert Uytterhoeven
@ 2011-08-29 12:55                   ` Laurent Pinchart
  -1 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-29 12:55 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Geert,

On Monday 29 August 2011 13:20:44 Geert Uytterhoeven wrote:
> On Mon, Aug 29, 2011 at 13:08, Laurent Pinchart wrote:
> > On Monday 29 August 2011 13:04:15 Geert Uytterhoeven wrote:
> >> On Mon, Aug 29, 2011 at 12:09, Laurent Pinchart wrote:
> >> > On Monday 29 August 2011 11:36:07 Geert Uytterhoeven wrote:
> >> >> On Mon, Aug 29, 2011 at 10:50, Laurent Pinchart wrote:
> >> [...]
> >> 
> >> > If my understanding is now correct, a V4L2 planar YUV type where Y, U
> >> > and V components are stored in separate byte-oriented planes, with
> >> > each plane storing Y, U or V components packed (such as
> >> > http://linuxtv.org/downloads/v4l- dvb-apis/V4L2-PIX-FMT-YUV422P.html),
> >> > would be of neither FB_TYPE_PLANES nor FB_TYPE_PACKED. The same would
> >> > be true for an RGB format where each component is stored in a
> >> > separate plane with each plane sotring R, G or B packed.
> >> 
> >> Indeed. Currently this cannot be represented.
> > 
> > Good, at least I now understand the situation :-)
> > 
> >> For ideas from the past, see e.g.
> >> http://comments.gmane.org/gmane.linux.fbdev.devel/10951.
> >> 
> >> > If the above is correct, what FB_TYPE_* should a driver report when
> >> > using FB_VISUAL_FOURCC with V4L2_PIX_FMT_YUV422P
> >> > (http://linuxtv.org/downloads/v4l- dvb-apis/V4L2-PIX-FMT-YUV422P.html)
> >> > or V4L2_PIX_FMT_NV12
> >> > (http://linuxtv.org/downloads/v4l-dvb-apis/re25.html) for instance ?
> >> 
> >> We need new types for those. Or always use FOURCC for them.
> > 
> > My proposal currently defined FB_VISUAL_FOURCC. What about adding
> > FB_TYPE_FOURCC as well ?
> 
> That may make sense.
> When will the driver report FB_{TYPE,VISUAL}_FOURCC?
>   - When using a mode that cannot be represented in the legacy way,

Definitely.

>   - But what with modes that can be represented? Legacy software cannot
>     handle FB_{TYPE,VISUAL}_FOURCC.

My idea was to use FB_{TYPE,VISUAL}_FOURCC only when the mode is configured 
using the FOURCC API. If FBIOPUT_VSCREENINFO is called with a non-FOURCC 
format, the driver will report non-FOURCC types and visuals.

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
@ 2011-08-29 12:55                   ` Laurent Pinchart
  0 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-29 12:55 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Geert,

On Monday 29 August 2011 13:20:44 Geert Uytterhoeven wrote:
> On Mon, Aug 29, 2011 at 13:08, Laurent Pinchart wrote:
> > On Monday 29 August 2011 13:04:15 Geert Uytterhoeven wrote:
> >> On Mon, Aug 29, 2011 at 12:09, Laurent Pinchart wrote:
> >> > On Monday 29 August 2011 11:36:07 Geert Uytterhoeven wrote:
> >> >> On Mon, Aug 29, 2011 at 10:50, Laurent Pinchart wrote:
> >> [...]
> >> 
> >> > If my understanding is now correct, a V4L2 planar YUV type where Y, U
> >> > and V components are stored in separate byte-oriented planes, with
> >> > each plane storing Y, U or V components packed (such as
> >> > http://linuxtv.org/downloads/v4l- dvb-apis/V4L2-PIX-FMT-YUV422P.html),
> >> > would be of neither FB_TYPE_PLANES nor FB_TYPE_PACKED. The same would
> >> > be true for an RGB format where each component is stored in a
> >> > separate plane with each plane sotring R, G or B packed.
> >> 
> >> Indeed. Currently this cannot be represented.
> > 
> > Good, at least I now understand the situation :-)
> > 
> >> For ideas from the past, see e.g.
> >> http://comments.gmane.org/gmane.linux.fbdev.devel/10951.
> >> 
> >> > If the above is correct, what FB_TYPE_* should a driver report when
> >> > using FB_VISUAL_FOURCC with V4L2_PIX_FMT_YUV422P
> >> > (http://linuxtv.org/downloads/v4l- dvb-apis/V4L2-PIX-FMT-YUV422P.html)
> >> > or V4L2_PIX_FMT_NV12
> >> > (http://linuxtv.org/downloads/v4l-dvb-apis/re25.html) for instance ?
> >> 
> >> We need new types for those. Or always use FOURCC for them.
> > 
> > My proposal currently defined FB_VISUAL_FOURCC. What about adding
> > FB_TYPE_FOURCC as well ?
> 
> That may make sense.
> When will the driver report FB_{TYPE,VISUAL}_FOURCC?
>   - When using a mode that cannot be represented in the legacy way,

Definitely.

>   - But what with modes that can be represented? Legacy software cannot
>     handle FB_{TYPE,VISUAL}_FOURCC.

My idea was to use FB_{TYPE,VISUAL}_FOURCC only when the mode is configured 
using the FOURCC API. If FBIOPUT_VSCREENINFO is called with a non-FOURCC 
format, the driver will report non-FOURCC types and visuals.

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
  2011-08-29 12:55                   ` Laurent Pinchart
@ 2011-08-29 13:09                     ` Geert Uytterhoeven
  -1 siblings, 0 replies; 52+ messages in thread
From: Geert Uytterhoeven @ 2011-08-29 13:09 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Laurent,

On Mon, Aug 29, 2011 at 14:55, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>> When will the driver report FB_{TYPE,VISUAL}_FOURCC?
>>   - When using a mode that cannot be represented in the legacy way,
>
> Definitely.
>
>>   - But what with modes that can be represented? Legacy software cannot
>>     handle FB_{TYPE,VISUAL}_FOURCC.
>
> My idea was to use FB_{TYPE,VISUAL}_FOURCC only when the mode is configured
> using the FOURCC API. If FBIOPUT_VSCREENINFO is called with a non-FOURCC
> format, the driver will report non-FOURCC types and visuals.

Hmm, two use cases:
  - The video mode is configured using a FOURCC-aware tool ("fbset on
steroids").
    Later the user runs a legacy application.
      => Do not retain FOURCC across opening of /dev/fb*.
  - Is there an easy way to force FOURCC reporting, so new apps don't have to
    support parsing the legacy formats? This is useful for new apps that want to
    support (a subset of) FOURCC modes only.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
@ 2011-08-29 13:09                     ` Geert Uytterhoeven
  0 siblings, 0 replies; 52+ messages in thread
From: Geert Uytterhoeven @ 2011-08-29 13:09 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Laurent,

On Mon, Aug 29, 2011 at 14:55, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>> When will the driver report FB_{TYPE,VISUAL}_FOURCC?
>>   - When using a mode that cannot be represented in the legacy way,
>
> Definitely.
>
>>   - But what with modes that can be represented? Legacy software cannot
>>     handle FB_{TYPE,VISUAL}_FOURCC.
>
> My idea was to use FB_{TYPE,VISUAL}_FOURCC only when the mode is configured
> using the FOURCC API. If FBIOPUT_VSCREENINFO is called with a non-FOURCC
> format, the driver will report non-FOURCC types and visuals.

Hmm, two use cases:
  - The video mode is configured using a FOURCC-aware tool ("fbset on
steroids").
    Later the user runs a legacy application.
      => Do not retain FOURCC across opening of /dev/fb*.
  - Is there an easy way to force FOURCC reporting, so new apps don't have to
    support parsing the legacy formats? This is useful for new apps that want to
    support (a subset of) FOURCC modes only.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
  2011-08-29 13:09                     ` Geert Uytterhoeven
@ 2011-08-29 13:34                       ` Laurent Pinchart
  -1 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-29 13:34 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Geert,

On Monday 29 August 2011 15:09:04 Geert Uytterhoeven wrote:
> On Mon, Aug 29, 2011 at 14:55, Laurent Pinchart wrote:
> >> When will the driver report FB_{TYPE,VISUAL}_FOURCC?
> >>   - When using a mode that cannot be represented in the legacy way,
> > 
> > Definitely.
> > 
> >>   - But what with modes that can be represented? Legacy software cannot
> >>     handle FB_{TYPE,VISUAL}_FOURCC.
> > 
> > My idea was to use FB_{TYPE,VISUAL}_FOURCC only when the mode is
> > configured using the FOURCC API. If FBIOPUT_VSCREENINFO is called with a
> > non-FOURCC format, the driver will report non-FOURCC types and visuals.
> 
> Hmm, two use cases:
>   - The video mode is configured using a FOURCC-aware tool ("fbset on
> steroids").

Such as http://git.ideasonboard.org/?p=fbdev-test.git;a=summary :-)

>     Later the user runs a legacy application.
>       => Do not retain FOURCC across opening of /dev/fb*.

I know about that problem, but it's not that easy to work around. We have no 
per-open fixed and variable screen info, and FB devices can be opened by 
multiple applications at the same time.

>   - Is there an easy way to force FOURCC reporting, so new apps don't have
> to support parsing the legacy formats? This is useful for new apps that
> want to support (a subset of) FOURCC modes only.

Not at the moment.

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
@ 2011-08-29 13:34                       ` Laurent Pinchart
  0 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-29 13:34 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Geert,

On Monday 29 August 2011 15:09:04 Geert Uytterhoeven wrote:
> On Mon, Aug 29, 2011 at 14:55, Laurent Pinchart wrote:
> >> When will the driver report FB_{TYPE,VISUAL}_FOURCC?
> >>   - When using a mode that cannot be represented in the legacy way,
> > 
> > Definitely.
> > 
> >>   - But what with modes that can be represented? Legacy software cannot
> >>     handle FB_{TYPE,VISUAL}_FOURCC.
> > 
> > My idea was to use FB_{TYPE,VISUAL}_FOURCC only when the mode is
> > configured using the FOURCC API. If FBIOPUT_VSCREENINFO is called with a
> > non-FOURCC format, the driver will report non-FOURCC types and visuals.
> 
> Hmm, two use cases:
>   - The video mode is configured using a FOURCC-aware tool ("fbset on
> steroids").

Such as http://git.ideasonboard.org/?pûdev-test.git;a=summary :-)

>     Later the user runs a legacy application.
>       => Do not retain FOURCC across opening of /dev/fb*.

I know about that problem, but it's not that easy to work around. We have no 
per-open fixed and variable screen info, and FB devices can be opened by 
multiple applications at the same time.

>   - Is there an easy way to force FOURCC reporting, so new apps don't have
> to support parsing the legacy formats? This is useful for new apps that
> want to support (a subset of) FOURCC modes only.

Not at the moment.

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
  2011-08-29 13:34                       ` Laurent Pinchart
@ 2011-08-29 14:14                         ` Geert Uytterhoeven
  -1 siblings, 0 replies; 52+ messages in thread
From: Geert Uytterhoeven @ 2011-08-29 14:14 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Laurent,

On Mon, Aug 29, 2011 at 15:34, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> On Monday 29 August 2011 15:09:04 Geert Uytterhoeven wrote:
>> On Mon, Aug 29, 2011 at 14:55, Laurent Pinchart wrote:
>> >> When will the driver report FB_{TYPE,VISUAL}_FOURCC?
>> >>   - When using a mode that cannot be represented in the legacy way,
>> >
>> > Definitely.
>> >
>> >>   - But what with modes that can be represented? Legacy software cannot
>> >>     handle FB_{TYPE,VISUAL}_FOURCC.
>> >
>> > My idea was to use FB_{TYPE,VISUAL}_FOURCC only when the mode is
>> > configured using the FOURCC API. If FBIOPUT_VSCREENINFO is called with a
>> > non-FOURCC format, the driver will report non-FOURCC types and visuals.
>>
>> Hmm, two use cases:
>>   - The video mode is configured using a FOURCC-aware tool ("fbset on
>> steroids").
>
> Such as http://git.ideasonboard.org/?p=fbdev-test.git;a=summary :-)

Yep.

>>     Later the user runs a legacy application.
>>       => Do not retain FOURCC across opening of /dev/fb*.
>
> I know about that problem, but it's not that easy to work around. We have no
> per-open fixed and variable screen info, and FB devices can be opened by
> multiple applications at the same time.
>
>>   - Is there an easy way to force FOURCC reporting, so new apps don't have
>> to support parsing the legacy formats? This is useful for new apps that
>> want to support (a subset of) FOURCC modes only.
>
> Not at the moment.

So perhaps we do need new ioctls instead...
That would also ease an in-kernel translation layer.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
@ 2011-08-29 14:14                         ` Geert Uytterhoeven
  0 siblings, 0 replies; 52+ messages in thread
From: Geert Uytterhoeven @ 2011-08-29 14:14 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Laurent,

On Mon, Aug 29, 2011 at 15:34, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> On Monday 29 August 2011 15:09:04 Geert Uytterhoeven wrote:
>> On Mon, Aug 29, 2011 at 14:55, Laurent Pinchart wrote:
>> >> When will the driver report FB_{TYPE,VISUAL}_FOURCC?
>> >>   - When using a mode that cannot be represented in the legacy way,
>> >
>> > Definitely.
>> >
>> >>   - But what with modes that can be represented? Legacy software cannot
>> >>     handle FB_{TYPE,VISUAL}_FOURCC.
>> >
>> > My idea was to use FB_{TYPE,VISUAL}_FOURCC only when the mode is
>> > configured using the FOURCC API. If FBIOPUT_VSCREENINFO is called with a
>> > non-FOURCC format, the driver will report non-FOURCC types and visuals.
>>
>> Hmm, two use cases:
>>   - The video mode is configured using a FOURCC-aware tool ("fbset on
>> steroids").
>
> Such as http://git.ideasonboard.org/?pûdev-test.git;a=summary :-)

Yep.

>>     Later the user runs a legacy application.
>>       => Do not retain FOURCC across opening of /dev/fb*.
>
> I know about that problem, but it's not that easy to work around. We have no
> per-open fixed and variable screen info, and FB devices can be opened by
> multiple applications at the same time.
>
>>   - Is there an easy way to force FOURCC reporting, so new apps don't have
>> to support parsing the legacy formats? This is useful for new apps that
>> want to support (a subset of) FOURCC modes only.
>
> Not at the moment.

So perhaps we do need new ioctls instead...
That would also ease an in-kernel translation layer.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
  2011-08-29 14:14                         ` Geert Uytterhoeven
@ 2011-08-29 14:17                           ` Laurent Pinchart
  -1 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-29 14:17 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Geert,

On Monday 29 August 2011 16:14:38 Geert Uytterhoeven wrote:
> On Mon, Aug 29, 2011 at 15:34, Laurent Pinchart wrote:
> > On Monday 29 August 2011 15:09:04 Geert Uytterhoeven wrote:
> >> On Mon, Aug 29, 2011 at 14:55, Laurent Pinchart wrote:
> >> >> When will the driver report FB_{TYPE,VISUAL}_FOURCC?
> >> >>   - When using a mode that cannot be represented in the legacy way,
> >> > 
> >> > Definitely.
> >> > 
> >> >>   - But what with modes that can be represented? Legacy software
> >> >> cannot handle FB_{TYPE,VISUAL}_FOURCC.
> >> > 
> >> > My idea was to use FB_{TYPE,VISUAL}_FOURCC only when the mode is
> >> > configured using the FOURCC API. If FBIOPUT_VSCREENINFO is called with
> >> > a non-FOURCC format, the driver will report non-FOURCC types and
> >> > visuals.
> >> 
> >> Hmm, two use cases:
> >>   - The video mode is configured using a FOURCC-aware tool ("fbset on
> >> steroids").
> > 
> > Such as http://git.ideasonboard.org/?p=fbdev-test.git;a=summary :-)
> 
> Yep.
> 
> >>     Later the user runs a legacy application.
> >>       => Do not retain FOURCC across opening of /dev/fb*.
> > 
> > I know about that problem, but it's not that easy to work around. We have
> > no per-open fixed and variable screen info, and FB devices can be opened
> > by multiple applications at the same time.
> > 
> >>   - Is there an easy way to force FOURCC reporting, so new apps don't
> >> have to support parsing the legacy formats? This is useful for new apps
> >> that want to support (a subset of) FOURCC modes only.
> > 
> > Not at the moment.
> 
> So perhaps we do need new ioctls instead...
> That would also ease an in-kernel translation layer.

Do you mean new ioctls to replace the FOURCC API proposal, or new ioctls for 
the above two operations ?

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
@ 2011-08-29 14:17                           ` Laurent Pinchart
  0 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-29 14:17 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Geert,

On Monday 29 August 2011 16:14:38 Geert Uytterhoeven wrote:
> On Mon, Aug 29, 2011 at 15:34, Laurent Pinchart wrote:
> > On Monday 29 August 2011 15:09:04 Geert Uytterhoeven wrote:
> >> On Mon, Aug 29, 2011 at 14:55, Laurent Pinchart wrote:
> >> >> When will the driver report FB_{TYPE,VISUAL}_FOURCC?
> >> >>   - When using a mode that cannot be represented in the legacy way,
> >> > 
> >> > Definitely.
> >> > 
> >> >>   - But what with modes that can be represented? Legacy software
> >> >> cannot handle FB_{TYPE,VISUAL}_FOURCC.
> >> > 
> >> > My idea was to use FB_{TYPE,VISUAL}_FOURCC only when the mode is
> >> > configured using the FOURCC API. If FBIOPUT_VSCREENINFO is called with
> >> > a non-FOURCC format, the driver will report non-FOURCC types and
> >> > visuals.
> >> 
> >> Hmm, two use cases:
> >>   - The video mode is configured using a FOURCC-aware tool ("fbset on
> >> steroids").
> > 
> > Such as http://git.ideasonboard.org/?pûdev-test.git;a=summary :-)
> 
> Yep.
> 
> >>     Later the user runs a legacy application.
> >>       => Do not retain FOURCC across opening of /dev/fb*.
> > 
> > I know about that problem, but it's not that easy to work around. We have
> > no per-open fixed and variable screen info, and FB devices can be opened
> > by multiple applications at the same time.
> > 
> >>   - Is there an easy way to force FOURCC reporting, so new apps don't
> >> have to support parsing the legacy formats? This is useful for new apps
> >> that want to support (a subset of) FOURCC modes only.
> > 
> > Not at the moment.
> 
> So perhaps we do need new ioctls instead...
> That would also ease an in-kernel translation layer.

Do you mean new ioctls to replace the FOURCC API proposal, or new ioctls for 
the above two operations ?

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
  2011-08-29 14:17                           ` Laurent Pinchart
@ 2011-08-29 14:26                             ` Geert Uytterhoeven
  -1 siblings, 0 replies; 52+ messages in thread
From: Geert Uytterhoeven @ 2011-08-29 14:26 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Laurent,

On Mon, Aug 29, 2011 at 16:17, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> On Monday 29 August 2011 16:14:38 Geert Uytterhoeven wrote:
>> On Mon, Aug 29, 2011 at 15:34, Laurent Pinchart wrote:
>> > On Monday 29 August 2011 15:09:04 Geert Uytterhoeven wrote:
>> >> On Mon, Aug 29, 2011 at 14:55, Laurent Pinchart wrote:
>> >> >> When will the driver report FB_{TYPE,VISUAL}_FOURCC?
>> >> >>   - When using a mode that cannot be represented in the legacy way,
>> >> >
>> >> > Definitely.
>> >> >
>> >> >>   - But what with modes that can be represented? Legacy software
>> >> >> cannot handle FB_{TYPE,VISUAL}_FOURCC.
>> >> >
>> >> > My idea was to use FB_{TYPE,VISUAL}_FOURCC only when the mode is
>> >> > configured using the FOURCC API. If FBIOPUT_VSCREENINFO is called with
>> >> > a non-FOURCC format, the driver will report non-FOURCC types and
>> >> > visuals.
>> >>
>> >> Hmm, two use cases:
>> >>   - The video mode is configured using a FOURCC-aware tool ("fbset on
>> >> steroids").
>> >
>> > Such as http://git.ideasonboard.org/?p=fbdev-test.git;a=summary :-)
>>
>> Yep.
>>
>> >>     Later the user runs a legacy application.
>> >>       => Do not retain FOURCC across opening of /dev/fb*.
>> >
>> > I know about that problem, but it's not that easy to work around. We have
>> > no per-open fixed and variable screen info, and FB devices can be opened
>> > by multiple applications at the same time.
>> >
>> >>   - Is there an easy way to force FOURCC reporting, so new apps don't
>> >> have to support parsing the legacy formats? This is useful for new apps
>> >> that want to support (a subset of) FOURCC modes only.
>> >
>> > Not at the moment.
>>
>> So perhaps we do need new ioctls instead...
>> That would also ease an in-kernel translation layer.
>
> Do you mean new ioctls to replace the FOURCC API proposal, or new ioctls for
> the above two operations ?

New ioctls to replace the FOURCC proposal.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
@ 2011-08-29 14:26                             ` Geert Uytterhoeven
  0 siblings, 0 replies; 52+ messages in thread
From: Geert Uytterhoeven @ 2011-08-29 14:26 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-fbdev, linux-media, magnus.damm

Hi Laurent,

On Mon, Aug 29, 2011 at 16:17, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> On Monday 29 August 2011 16:14:38 Geert Uytterhoeven wrote:
>> On Mon, Aug 29, 2011 at 15:34, Laurent Pinchart wrote:
>> > On Monday 29 August 2011 15:09:04 Geert Uytterhoeven wrote:
>> >> On Mon, Aug 29, 2011 at 14:55, Laurent Pinchart wrote:
>> >> >> When will the driver report FB_{TYPE,VISUAL}_FOURCC?
>> >> >>   - When using a mode that cannot be represented in the legacy way,
>> >> >
>> >> > Definitely.
>> >> >
>> >> >>   - But what with modes that can be represented? Legacy software
>> >> >> cannot handle FB_{TYPE,VISUAL}_FOURCC.
>> >> >
>> >> > My idea was to use FB_{TYPE,VISUAL}_FOURCC only when the mode is
>> >> > configured using the FOURCC API. If FBIOPUT_VSCREENINFO is called with
>> >> > a non-FOURCC format, the driver will report non-FOURCC types and
>> >> > visuals.
>> >>
>> >> Hmm, two use cases:
>> >>   - The video mode is configured using a FOURCC-aware tool ("fbset on
>> >> steroids").
>> >
>> > Such as http://git.ideasonboard.org/?pûdev-test.git;a=summary :-)
>>
>> Yep.
>>
>> >>     Later the user runs a legacy application.
>> >>       => Do not retain FOURCC across opening of /dev/fb*.
>> >
>> > I know about that problem, but it's not that easy to work around. We have
>> > no per-open fixed and variable screen info, and FB devices can be opened
>> > by multiple applications at the same time.
>> >
>> >>   - Is there an easy way to force FOURCC reporting, so new apps don't
>> >> have to support parsing the legacy formats? This is useful for new apps
>> >> that want to support (a subset of) FOURCC modes only.
>> >
>> > Not at the moment.
>>
>> So perhaps we do need new ioctls instead...
>> That would also ease an in-kernel translation layer.
>
> Do you mean new ioctls to replace the FOURCC API proposal, or new ioctls for
> the above two operations ?

New ioctls to replace the FOURCC proposal.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
  2011-08-29 14:26                             ` Geert Uytterhoeven
@ 2011-08-29 14:32                               ` Laurent Pinchart
  -1 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-29 14:32 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: linux-fbdev, linux-media, magnus.damm, Florian Tobias Schandinat,
	Guennadi Liakhovetski

Hi Geert,

On Monday 29 August 2011 16:26:02 Geert Uytterhoeven wrote:
> On Mon, Aug 29, 2011 at 16:17, Laurent Pinchart wrote:
> > On Monday 29 August 2011 16:14:38 Geert Uytterhoeven wrote:
> >> On Mon, Aug 29, 2011 at 15:34, Laurent Pinchart wrote:
> >> > On Monday 29 August 2011 15:09:04 Geert Uytterhoeven wrote:
> >> >> On Mon, Aug 29, 2011 at 14:55, Laurent Pinchart wrote:
> >> >> >> When will the driver report FB_{TYPE,VISUAL}_FOURCC?
> >> >> >>   - When using a mode that cannot be represented in the legacy
> >> >> >> way,
> >> >> > 
> >> >> > Definitely.
> >> >> > 
> >> >> >>   - But what with modes that can be represented? Legacy software
> >> >> >> cannot handle FB_{TYPE,VISUAL}_FOURCC.
> >> >> > 
> >> >> > My idea was to use FB_{TYPE,VISUAL}_FOURCC only when the mode is
> >> >> > configured using the FOURCC API. If FBIOPUT_VSCREENINFO is called
> >> >> > with a non-FOURCC format, the driver will report non-FOURCC types
> >> >> > and visuals.
> >> >> 
> >> >> Hmm, two use cases:
> >> >>   - The video mode is configured using a FOURCC-aware tool ("fbset on
> >> >> steroids").
> >> > 
> >> > Such as http://git.ideasonboard.org/?p=fbdev-test.git;a=summary :-)
> >> 
> >> Yep.
> >> 
> >> >>     Later the user runs a legacy application.
> >> >>       => Do not retain FOURCC across opening of /dev/fb*.
> >> > 
> >> > I know about that problem, but it's not that easy to work around. We
> >> > have no per-open fixed and variable screen info, and FB devices can
> >> > be opened by multiple applications at the same time.
> >> > 
> >> >>   - Is there an easy way to force FOURCC reporting, so new apps don't
> >> >> have to support parsing the legacy formats? This is useful for new
> >> >> apps that want to support (a subset of) FOURCC modes only.
> >> > 
> >> > Not at the moment.
> >> 
> >> So perhaps we do need new ioctls instead...
> >> That would also ease an in-kernel translation layer.
> > 
> > Do you mean new ioctls to replace the FOURCC API proposal, or new ioctls
> > for the above two operations ?
> 
> New ioctls to replace the FOURCC proposal.

*sigh*...

I'd like other people's opinion on this before throwing everything away. 
Florian, Magnus, Guennadi, others, what do you think ?

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
@ 2011-08-29 14:32                               ` Laurent Pinchart
  0 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-29 14:32 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: linux-fbdev, linux-media, magnus.damm, Florian Tobias Schandinat,
	Guennadi Liakhovetski

Hi Geert,

On Monday 29 August 2011 16:26:02 Geert Uytterhoeven wrote:
> On Mon, Aug 29, 2011 at 16:17, Laurent Pinchart wrote:
> > On Monday 29 August 2011 16:14:38 Geert Uytterhoeven wrote:
> >> On Mon, Aug 29, 2011 at 15:34, Laurent Pinchart wrote:
> >> > On Monday 29 August 2011 15:09:04 Geert Uytterhoeven wrote:
> >> >> On Mon, Aug 29, 2011 at 14:55, Laurent Pinchart wrote:
> >> >> >> When will the driver report FB_{TYPE,VISUAL}_FOURCC?
> >> >> >>   - When using a mode that cannot be represented in the legacy
> >> >> >> way,
> >> >> > 
> >> >> > Definitely.
> >> >> > 
> >> >> >>   - But what with modes that can be represented? Legacy software
> >> >> >> cannot handle FB_{TYPE,VISUAL}_FOURCC.
> >> >> > 
> >> >> > My idea was to use FB_{TYPE,VISUAL}_FOURCC only when the mode is
> >> >> > configured using the FOURCC API. If FBIOPUT_VSCREENINFO is called
> >> >> > with a non-FOURCC format, the driver will report non-FOURCC types
> >> >> > and visuals.
> >> >> 
> >> >> Hmm, two use cases:
> >> >>   - The video mode is configured using a FOURCC-aware tool ("fbset on
> >> >> steroids").
> >> > 
> >> > Such as http://git.ideasonboard.org/?pûdev-test.git;a=summary :-)
> >> 
> >> Yep.
> >> 
> >> >>     Later the user runs a legacy application.
> >> >>       => Do not retain FOURCC across opening of /dev/fb*.
> >> > 
> >> > I know about that problem, but it's not that easy to work around. We
> >> > have no per-open fixed and variable screen info, and FB devices can
> >> > be opened by multiple applications at the same time.
> >> > 
> >> >>   - Is there an easy way to force FOURCC reporting, so new apps don't
> >> >> have to support parsing the legacy formats? This is useful for new
> >> >> apps that want to support (a subset of) FOURCC modes only.
> >> > 
> >> > Not at the moment.
> >> 
> >> So perhaps we do need new ioctls instead...
> >> That would also ease an in-kernel translation layer.
> > 
> > Do you mean new ioctls to replace the FOURCC API proposal, or new ioctls
> > for the above two operations ?
> 
> New ioctls to replace the FOURCC proposal.

*sigh*...

I'd like other people's opinion on this before throwing everything away. 
Florian, Magnus, Guennadi, others, what do you think ?

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
  2011-08-29 14:32                               ` Laurent Pinchart
@ 2011-08-29 16:41                                 ` Florian Tobias Schandinat
  -1 siblings, 0 replies; 52+ messages in thread
From: Florian Tobias Schandinat @ 2011-08-29 16:41 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Geert Uytterhoeven, linux-fbdev, linux-media, magnus.damm,
	Guennadi Liakhovetski

Hi,

On 08/29/2011 02:32 PM, Laurent Pinchart wrote:
> Hi Geert,
> 
> On Monday 29 August 2011 16:26:02 Geert Uytterhoeven wrote:
>> On Mon, Aug 29, 2011 at 16:17, Laurent Pinchart wrote:
>>> On Monday 29 August 2011 16:14:38 Geert Uytterhoeven wrote:
>>>> On Mon, Aug 29, 2011 at 15:34, Laurent Pinchart wrote:
>>>>> On Monday 29 August 2011 15:09:04 Geert Uytterhoeven wrote:
>>>>>> On Mon, Aug 29, 2011 at 14:55, Laurent Pinchart wrote:
>>>>>>>> When will the driver report FB_{TYPE,VISUAL}_FOURCC?
>>>>>>>>   - When using a mode that cannot be represented in the legacy
>>>>>>>> way,
>>>>>>>
>>>>>>> Definitely.
>>>>>>>
>>>>>>>>   - But what with modes that can be represented? Legacy software
>>>>>>>> cannot handle FB_{TYPE,VISUAL}_FOURCC.
>>>>>>>
>>>>>>> My idea was to use FB_{TYPE,VISUAL}_FOURCC only when the mode is
>>>>>>> configured using the FOURCC API. If FBIOPUT_VSCREENINFO is called
>>>>>>> with a non-FOURCC format, the driver will report non-FOURCC types
>>>>>>> and visuals.
>>>>>>
>>>>>> Hmm, two use cases:
>>>>>>   - The video mode is configured using a FOURCC-aware tool ("fbset on
>>>>>> steroids").
>>>>>
>>>>> Such as http://git.ideasonboard.org/?p=fbdev-test.git;a=summary :-)
>>>>
>>>> Yep.
>>>>
>>>>>>     Later the user runs a legacy application.
>>>>>>       => Do not retain FOURCC across opening of /dev/fb*.
>>>>>
>>>>> I know about that problem, but it's not that easy to work around. We
>>>>> have no per-open fixed and variable screen info, and FB devices can
>>>>> be opened by multiple applications at the same time.
>>>>>
>>>>>>   - Is there an easy way to force FOURCC reporting, so new apps don't
>>>>>> have to support parsing the legacy formats? This is useful for new
>>>>>> apps that want to support (a subset of) FOURCC modes only.
>>>>>
>>>>> Not at the moment.
>>>>
>>>> So perhaps we do need new ioctls instead...
>>>> That would also ease an in-kernel translation layer.
>>>
>>> Do you mean new ioctls to replace the FOURCC API proposal, or new ioctls
>>> for the above two operations ?
>>
>> New ioctls to replace the FOURCC proposal.
> 
> *sigh*...
> 
> I'd like other people's opinion on this before throwing everything away. 
> Florian, Magnus, Guennadi, others, what do you think ?
> 

So, your issue is that some formats can be represented in the new and the old way?
There are 2 simpler solutions I can think of:

(1) ignore it, just do it the way Laurent proposed. I understand that someone
might feel uneasy about applications that are trapped because they don't know
the new format but could work with the old one. But I think this is not a big
issue as many applications will just try to set their own mode. For those that
doesn't and rely on the previous mode that is set by fbset or similar, we could
change fbset to prefer the old format if available. But even if we don't do
this, I don't have a problem with a program failing because it sees an
unsuitable mode even if it supports the legacy mode. It's not a regression and
can be easily fixed in userspace.

(2) forbid it, just allow drivers to implement FOURCC for formats that cannot be
represented in the old scheme. This is my preferred solution if anyone has
problems with (1).

I don't see how IOCTLs would help here. The pixel format just belongs into var
and fix so it has to be represented there anyway and thus set through it. We
could do an IOCTL that always returns the FOURCC active at the moment, if such a
FOURCC exists, and always use the legacy API for representing it in var/fix, if
it exists. But as I see this is not what you thought about so please explain
what your IOCTLS would look like and how they would solve the problem.

And I don't think a in-kernel translation layer is a good idea. Yes, it sounds
interesting, but it's tricky and the result will be that the driver and
userspace will permanently see different var and fix structures. Seriously I
think changing every framebuffer driver out there would be easier and much saner
than trying to implement such a thing.


Best regards,

Florian Tobias Schandinat

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration
@ 2011-08-29 16:41                                 ` Florian Tobias Schandinat
  0 siblings, 0 replies; 52+ messages in thread
From: Florian Tobias Schandinat @ 2011-08-29 16:41 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Geert Uytterhoeven, linux-fbdev, linux-media, magnus.damm,
	Guennadi Liakhovetski

Hi,

On 08/29/2011 02:32 PM, Laurent Pinchart wrote:
> Hi Geert,
> 
> On Monday 29 August 2011 16:26:02 Geert Uytterhoeven wrote:
>> On Mon, Aug 29, 2011 at 16:17, Laurent Pinchart wrote:
>>> On Monday 29 August 2011 16:14:38 Geert Uytterhoeven wrote:
>>>> On Mon, Aug 29, 2011 at 15:34, Laurent Pinchart wrote:
>>>>> On Monday 29 August 2011 15:09:04 Geert Uytterhoeven wrote:
>>>>>> On Mon, Aug 29, 2011 at 14:55, Laurent Pinchart wrote:
>>>>>>>> When will the driver report FB_{TYPE,VISUAL}_FOURCC?
>>>>>>>>   - When using a mode that cannot be represented in the legacy
>>>>>>>> way,
>>>>>>>
>>>>>>> Definitely.
>>>>>>>
>>>>>>>>   - But what with modes that can be represented? Legacy software
>>>>>>>> cannot handle FB_{TYPE,VISUAL}_FOURCC.
>>>>>>>
>>>>>>> My idea was to use FB_{TYPE,VISUAL}_FOURCC only when the mode is
>>>>>>> configured using the FOURCC API. If FBIOPUT_VSCREENINFO is called
>>>>>>> with a non-FOURCC format, the driver will report non-FOURCC types
>>>>>>> and visuals.
>>>>>>
>>>>>> Hmm, two use cases:
>>>>>>   - The video mode is configured using a FOURCC-aware tool ("fbset on
>>>>>> steroids").
>>>>>
>>>>> Such as http://git.ideasonboard.org/?pûdev-test.git;a=summary :-)
>>>>
>>>> Yep.
>>>>
>>>>>>     Later the user runs a legacy application.
>>>>>>       => Do not retain FOURCC across opening of /dev/fb*.
>>>>>
>>>>> I know about that problem, but it's not that easy to work around. We
>>>>> have no per-open fixed and variable screen info, and FB devices can
>>>>> be opened by multiple applications at the same time.
>>>>>
>>>>>>   - Is there an easy way to force FOURCC reporting, so new apps don't
>>>>>> have to support parsing the legacy formats? This is useful for new
>>>>>> apps that want to support (a subset of) FOURCC modes only.
>>>>>
>>>>> Not at the moment.
>>>>
>>>> So perhaps we do need new ioctls instead...
>>>> That would also ease an in-kernel translation layer.
>>>
>>> Do you mean new ioctls to replace the FOURCC API proposal, or new ioctls
>>> for the above two operations ?
>>
>> New ioctls to replace the FOURCC proposal.
> 
> *sigh*...
> 
> I'd like other people's opinion on this before throwing everything away. 
> Florian, Magnus, Guennadi, others, what do you think ?
> 

So, your issue is that some formats can be represented in the new and the old way?
There are 2 simpler solutions I can think of:

(1) ignore it, just do it the way Laurent proposed. I understand that someone
might feel uneasy about applications that are trapped because they don't know
the new format but could work with the old one. But I think this is not a big
issue as many applications will just try to set their own mode. For those that
doesn't and rely on the previous mode that is set by fbset or similar, we could
change fbset to prefer the old format if available. But even if we don't do
this, I don't have a problem with a program failing because it sees an
unsuitable mode even if it supports the legacy mode. It's not a regression and
can be easily fixed in userspace.

(2) forbid it, just allow drivers to implement FOURCC for formats that cannot be
represented in the old scheme. This is my preferred solution if anyone has
problems with (1).

I don't see how IOCTLs would help here. The pixel format just belongs into var
and fix so it has to be represented there anyway and thus set through it. We
could do an IOCTL that always returns the FOURCC active at the moment, if such a
FOURCC exists, and always use the legacy API for representing it in var/fix, if
it exists. But as I see this is not what you thought about so please explain
what your IOCTLS would look like and how they would solve the problem.

And I don't think a in-kernel translation layer is a good idea. Yes, it sounds
interesting, but it's tricky and the result will be that the driver and
userspace will permanently see different var and fix structures. Seriously I
think changing every framebuffer driver out there would be easier and much saner
than trying to implement such a thing.


Best regards,

Florian Tobias Schandinat

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
  2011-08-29 16:41                                 ` [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration Florian Tobias Schandinat
@ 2011-08-30  1:09                                   ` Laurent Pinchart
  -1 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-30  1:09 UTC (permalink / raw)
  To: Florian Tobias Schandinat
  Cc: Geert Uytterhoeven, linux-fbdev, linux-media, magnus.damm,
	Guennadi Liakhovetski

Hi Florian,

On Monday 29 August 2011 18:41:03 Florian Tobias Schandinat wrote:
> On 08/29/2011 02:32 PM, Laurent Pinchart wrote:
> > On Monday 29 August 2011 16:26:02 Geert Uytterhoeven wrote:
> >> On Mon, Aug 29, 2011 at 16:17, Laurent Pinchart wrote:
> >>> On Monday 29 August 2011 16:14:38 Geert Uytterhoeven wrote:
> >>>> On Mon, Aug 29, 2011 at 15:34, Laurent Pinchart wrote:
> >>>>> On Monday 29 August 2011 15:09:04 Geert Uytterhoeven wrote:
> >>>>>> On Mon, Aug 29, 2011 at 14:55, Laurent Pinchart wrote:
> >>>>>>>> When will the driver report FB_{TYPE,VISUAL}_FOURCC?
> >>>>>>>> 
> >>>>>>>>   - When using a mode that cannot be represented in the legacy
> >>>>>>>> 
> >>>>>>>> way,
> >>>>>>> 
> >>>>>>> Definitely.
> >>>>>>> 
> >>>>>>>>   - But what with modes that can be represented? Legacy software
> >>>>>>>> 
> >>>>>>>> cannot handle FB_{TYPE,VISUAL}_FOURCC.
> >>>>>>> 
> >>>>>>> My idea was to use FB_{TYPE,VISUAL}_FOURCC only when the mode is
> >>>>>>> configured using the FOURCC API. If FBIOPUT_VSCREENINFO is called
> >>>>>>> with a non-FOURCC format, the driver will report non-FOURCC types
> >>>>>>> and visuals.
> >>>>>> 
> >>>>>> Hmm, two use cases:
> >>>>>>   - The video mode is configured using a FOURCC-aware tool ("fbset
> >>>>>>   on
> >>>>>> 
> >>>>>> steroids").
> >>>>> 
> >>>>> Such as http://git.ideasonboard.org/?p=fbdev-test.git;a=summary :-)
> >>>> 
> >>>> Yep.
> >>>> 
> >>>>>>     Later the user runs a legacy application.
> >>>>>>     
> >>>>>>       => Do not retain FOURCC across opening of /dev/fb*.
> >>>>> 
> >>>>> I know about that problem, but it's not that easy to work around. We
> >>>>> have no per-open fixed and variable screen info, and FB devices can
> >>>>> be opened by multiple applications at the same time.
> >>>>> 
> >>>>>>   - Is there an easy way to force FOURCC reporting, so new apps
> >>>>>>   don't
> >>>>>> 
> >>>>>> have to support parsing the legacy formats? This is useful for new
> >>>>>> apps that want to support (a subset of) FOURCC modes only.
> >>>>> 
> >>>>> Not at the moment.
> >>>> 
> >>>> So perhaps we do need new ioctls instead...
> >>>> That would also ease an in-kernel translation layer.
> >>> 
> >>> Do you mean new ioctls to replace the FOURCC API proposal, or new
> >>> ioctls for the above two operations ?
> >> 
> >> New ioctls to replace the FOURCC proposal.
> > 
> > *sigh*...
> > 
> > I'd like other people's opinion on this before throwing everything away.
> > Florian, Magnus, Guennadi, others, what do you think ?
> 
> So, your issue is that some formats can be represented in the new and the
> old way? There are 2 simpler solutions I can think of:
> 
> (1) ignore it, just do it the way Laurent proposed. I understand that
> someone might feel uneasy about applications that are trapped because they
> don't know the new format but could work with the old one. But I think
> this is not a big issue as many applications will just try to set their
> own mode. For those that doesn't and rely on the previous mode that is set
> by fbset or similar, we could change fbset to prefer the old format if
> available. But even if we don't do this, I don't have a problem with a
> program failing because it sees an unsuitable mode even if it supports the
> legacy mode. It's not a regression and can be easily fixed in userspace.

I agree with you here. Issues should be fixed in userspace. I don't expect 
many issues in practice, as fbdev is often used on systems where userspace 
components are developed to work with each other (such as embedded systems). 
If such a system is upgraded to use YUV support, all components will likely be 
tested and upgraded.

> (2) forbid it, just allow drivers to implement FOURCC for formats that
> cannot be represented in the old scheme. This is my preferred solution if
> anyone has problems with (1).

I'm tempted by that solution. Not that I have an issue with (1), but I'm 
wondering if we should try to use the FOURCC API for all formats, or just for 
formats that can't be represented by the current API. We currently have no 
bitplane FOURCCs, and I'm not sure if it would be worth adding them.

BTW, do recent hardware still support planar (in the bitplane sense) frame 
buffers ? If so, is that used in practice on recent devices ? If the answer is 
no, (1) might be the best solution, with bit-planar formats supported by the 
current API only, and all other formats supported by the FOURCC API.

> I don't see how IOCTLs would help here. The pixel format just belongs into
> var and fix so it has to be represented there anyway and thus set through
> it. We could do an IOCTL that always returns the FOURCC active at the
> moment, if such a FOURCC exists, and always use the legacy API for
> representing it in var/fix, if it exists. But as I see this is not what
> you thought about so please explain what your IOCTLS would look like and
> how they would solve the problem.
> 
> And I don't think a in-kernel translation layer is a good idea. Yes, it
> sounds interesting, but it's tricky and the result will be that the driver
> and userspace will permanently see different var and fix structures.
> Seriously I think changing every framebuffer driver out there would be
> easier and much saner than trying to implement such a thing.

I agree.

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API
@ 2011-08-30  1:09                                   ` Laurent Pinchart
  0 siblings, 0 replies; 52+ messages in thread
From: Laurent Pinchart @ 2011-08-30  1:09 UTC (permalink / raw)
  To: Florian Tobias Schandinat
  Cc: Geert Uytterhoeven, linux-fbdev, linux-media, magnus.damm,
	Guennadi Liakhovetski

Hi Florian,

On Monday 29 August 2011 18:41:03 Florian Tobias Schandinat wrote:
> On 08/29/2011 02:32 PM, Laurent Pinchart wrote:
> > On Monday 29 August 2011 16:26:02 Geert Uytterhoeven wrote:
> >> On Mon, Aug 29, 2011 at 16:17, Laurent Pinchart wrote:
> >>> On Monday 29 August 2011 16:14:38 Geert Uytterhoeven wrote:
> >>>> On Mon, Aug 29, 2011 at 15:34, Laurent Pinchart wrote:
> >>>>> On Monday 29 August 2011 15:09:04 Geert Uytterhoeven wrote:
> >>>>>> On Mon, Aug 29, 2011 at 14:55, Laurent Pinchart wrote:
> >>>>>>>> When will the driver report FB_{TYPE,VISUAL}_FOURCC?
> >>>>>>>> 
> >>>>>>>>   - When using a mode that cannot be represented in the legacy
> >>>>>>>> 
> >>>>>>>> way,
> >>>>>>> 
> >>>>>>> Definitely.
> >>>>>>> 
> >>>>>>>>   - But what with modes that can be represented? Legacy software
> >>>>>>>> 
> >>>>>>>> cannot handle FB_{TYPE,VISUAL}_FOURCC.
> >>>>>>> 
> >>>>>>> My idea was to use FB_{TYPE,VISUAL}_FOURCC only when the mode is
> >>>>>>> configured using the FOURCC API. If FBIOPUT_VSCREENINFO is called
> >>>>>>> with a non-FOURCC format, the driver will report non-FOURCC types
> >>>>>>> and visuals.
> >>>>>> 
> >>>>>> Hmm, two use cases:
> >>>>>>   - The video mode is configured using a FOURCC-aware tool ("fbset
> >>>>>>   on
> >>>>>> 
> >>>>>> steroids").
> >>>>> 
> >>>>> Such as http://git.ideasonboard.org/?pûdev-test.git;a=summary :-)
> >>>> 
> >>>> Yep.
> >>>> 
> >>>>>>     Later the user runs a legacy application.
> >>>>>>     
> >>>>>>       => Do not retain FOURCC across opening of /dev/fb*.
> >>>>> 
> >>>>> I know about that problem, but it's not that easy to work around. We
> >>>>> have no per-open fixed and variable screen info, and FB devices can
> >>>>> be opened by multiple applications at the same time.
> >>>>> 
> >>>>>>   - Is there an easy way to force FOURCC reporting, so new apps
> >>>>>>   don't
> >>>>>> 
> >>>>>> have to support parsing the legacy formats? This is useful for new
> >>>>>> apps that want to support (a subset of) FOURCC modes only.
> >>>>> 
> >>>>> Not at the moment.
> >>>> 
> >>>> So perhaps we do need new ioctls instead...
> >>>> That would also ease an in-kernel translation layer.
> >>> 
> >>> Do you mean new ioctls to replace the FOURCC API proposal, or new
> >>> ioctls for the above two operations ?
> >> 
> >> New ioctls to replace the FOURCC proposal.
> > 
> > *sigh*...
> > 
> > I'd like other people's opinion on this before throwing everything away.
> > Florian, Magnus, Guennadi, others, what do you think ?
> 
> So, your issue is that some formats can be represented in the new and the
> old way? There are 2 simpler solutions I can think of:
> 
> (1) ignore it, just do it the way Laurent proposed. I understand that
> someone might feel uneasy about applications that are trapped because they
> don't know the new format but could work with the old one. But I think
> this is not a big issue as many applications will just try to set their
> own mode. For those that doesn't and rely on the previous mode that is set
> by fbset or similar, we could change fbset to prefer the old format if
> available. But even if we don't do this, I don't have a problem with a
> program failing because it sees an unsuitable mode even if it supports the
> legacy mode. It's not a regression and can be easily fixed in userspace.

I agree with you here. Issues should be fixed in userspace. I don't expect 
many issues in practice, as fbdev is often used on systems where userspace 
components are developed to work with each other (such as embedded systems). 
If such a system is upgraded to use YUV support, all components will likely be 
tested and upgraded.

> (2) forbid it, just allow drivers to implement FOURCC for formats that
> cannot be represented in the old scheme. This is my preferred solution if
> anyone has problems with (1).

I'm tempted by that solution. Not that I have an issue with (1), but I'm 
wondering if we should try to use the FOURCC API for all formats, or just for 
formats that can't be represented by the current API. We currently have no 
bitplane FOURCCs, and I'm not sure if it would be worth adding them.

BTW, do recent hardware still support planar (in the bitplane sense) frame 
buffers ? If so, is that used in practice on recent devices ? If the answer is 
no, (1) might be the best solution, with bit-planar formats supported by the 
current API only, and all other formats supported by the FOURCC API.

> I don't see how IOCTLs would help here. The pixel format just belongs into
> var and fix so it has to be represented there anyway and thus set through
> it. We could do an IOCTL that always returns the FOURCC active at the
> moment, if such a FOURCC exists, and always use the legacy API for
> representing it in var/fix, if it exists. But as I see this is not what
> you thought about so please explain what your IOCTLS would look like and
> how they would solve the problem.
> 
> And I don't think a in-kernel translation layer is a good idea. Yes, it
> sounds interesting, but it's tricky and the result will be that the driver
> and userspace will permanently see different var and fix structures.
> Seriously I think changing every framebuffer driver out there would be
> easier and much saner than trying to implement such a thing.

I agree.

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 52+ messages in thread

end of thread, other threads:[~2011-08-30  1:09 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-19  9:37 [PATCH/RFC v2 0/3] fbdev: Add FOURCC-based format configuration API Laurent Pinchart
2011-08-19  9:37 ` Laurent Pinchart
2011-08-19  9:37 ` [PATCH/RFC v2 1/3] " Laurent Pinchart
2011-08-19  9:37   ` Laurent Pinchart
2011-08-26 17:07   ` Florian Tobias Schandinat
2011-08-26 17:07     ` [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration Florian Tobias Schandinat
2011-08-28  8:48     ` [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API Laurent Pinchart
2011-08-28  8:48       ` Laurent Pinchart
2011-08-29  8:13   ` Geert Uytterhoeven
2011-08-29  8:13     ` Geert Uytterhoeven
2011-08-29  8:50     ` Laurent Pinchart
2011-08-29  8:50       ` Laurent Pinchart
2011-08-29  9:36       ` Geert Uytterhoeven
2011-08-29  9:36         ` Geert Uytterhoeven
2011-08-29 10:09         ` Laurent Pinchart
2011-08-29 10:09           ` Laurent Pinchart
2011-08-29 11:04           ` Geert Uytterhoeven
2011-08-29 11:04             ` Geert Uytterhoeven
2011-08-29 11:08             ` Laurent Pinchart
2011-08-29 11:08               ` Laurent Pinchart
2011-08-29 11:20               ` Geert Uytterhoeven
2011-08-29 11:20                 ` Geert Uytterhoeven
2011-08-29 12:55                 ` Laurent Pinchart
2011-08-29 12:55                   ` Laurent Pinchart
2011-08-29 13:09                   ` Geert Uytterhoeven
2011-08-29 13:09                     ` Geert Uytterhoeven
2011-08-29 13:34                     ` Laurent Pinchart
2011-08-29 13:34                       ` Laurent Pinchart
2011-08-29 14:14                       ` Geert Uytterhoeven
2011-08-29 14:14                         ` Geert Uytterhoeven
2011-08-29 14:17                         ` Laurent Pinchart
2011-08-29 14:17                           ` Laurent Pinchart
2011-08-29 14:26                           ` Geert Uytterhoeven
2011-08-29 14:26                             ` Geert Uytterhoeven
2011-08-29 14:32                             ` Laurent Pinchart
2011-08-29 14:32                               ` Laurent Pinchart
2011-08-29 16:41                               ` Florian Tobias Schandinat
2011-08-29 16:41                                 ` [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration Florian Tobias Schandinat
2011-08-30  1:09                                 ` [PATCH/RFC v2 1/3] fbdev: Add FOURCC-based format configuration API Laurent Pinchart
2011-08-30  1:09                                   ` Laurent Pinchart
2011-08-19  9:37 ` [PATCH/RFC v2 2/3] v4l: Add V4L2_PIX_FMT_NV24 and V4L2_PIX_FMT_NV42 formats Laurent Pinchart
2011-08-19  9:37   ` Laurent Pinchart
2011-08-19  9:37 ` [PATCH/RFC v2 3/3] fbdev: sh_mobile_lcdc: Support FOURCC-based format API Laurent Pinchart
2011-08-19  9:37   ` Laurent Pinchart
2011-08-26 17:24   ` Florian Tobias Schandinat
2011-08-26 17:24     ` [PATCH/RFC v2 3/3] fbdev: sh_mobile_lcdc: Support FOURCC-based Florian Tobias Schandinat
2011-08-28  8:59     ` [PATCH/RFC v2 3/3] fbdev: sh_mobile_lcdc: Support FOURCC-based format API Laurent Pinchart
2011-08-28  8:59       ` Laurent Pinchart
2011-08-29  0:39   ` Magnus Damm
2011-08-29  0:39     ` [PATCH/RFC v2 3/3] fbdev: sh_mobile_lcdc: Support FOURCC-based Magnus Damm
2011-08-29  8:30     ` [PATCH/RFC v2 3/3] fbdev: sh_mobile_lcdc: Support FOURCC-based format API Laurent Pinchart
2011-08-29  8:30       ` Laurent Pinchart

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.