[media] v4l: Support extending the v4l2_pix_format structure
The v4l2_pix_format structure has no reserved field. It is embedded in the v4l2_framebuffer structure which has no reserved fields either, and in the v4l2_format structure which has reserved fields that were not previously required to be zeroed out by applications. To allow extending v4l2_pix_format, inline it in the v4l2_framebuffer structure, and use the priv field as a magic value to indicate that the application has set all v4l2_pix_format extended fields and zeroed all reserved fields following the v4l2_pix_format field in the v4l2_format structure. The availability of this API extension is reported to userspace through the new V4L2_CAP_EXT_PIX_FORMAT capability flag. Just checking that the priv field is still set to the magic value at [GS]_FMT return wouldn't be enough, as older kernels don't zero the priv field on return. To simplify the internal API towards drivers zero the extended fields and set the priv field to the magic value for applications not aware of the extensions. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
This commit is contained in:
		
					parent
					
						
							
								b04ef7c075
							
						
					
				
			
			
				commit
				
					
						d52e238136
					
				
			
		
					 31 changed files with 134 additions and 70 deletions
				
			
		|  | @ -268,6 +268,7 @@ struct v4l2_capability { | |||
| #define V4L2_CAP_MODULATOR		0x00080000  /* has a modulator */ | ||||
| 
 | ||||
| #define V4L2_CAP_SDR_CAPTURE		0x00100000  /* Is a SDR capture device */ | ||||
| #define V4L2_CAP_EXT_PIX_FORMAT		0x00200000  /* Supports the extended pixel format */ | ||||
| 
 | ||||
| #define V4L2_CAP_READWRITE              0x01000000  /* read/write systemcalls */ | ||||
| #define V4L2_CAP_ASYNCIO                0x02000000  /* async I/O */ | ||||
|  | @ -448,6 +449,9 @@ struct v4l2_pix_format { | |||
| #define V4L2_SDR_FMT_CU8          v4l2_fourcc('C', 'U', '0', '8') /* IQ u8 */ | ||||
| #define V4L2_SDR_FMT_CU16LE       v4l2_fourcc('C', 'U', '1', '6') /* IQ u16le */ | ||||
| 
 | ||||
| /* priv field value to indicates that subsequent fields are valid. */ | ||||
| #define V4L2_PIX_FMT_PRIV_MAGIC		0xfeedcafe | ||||
| 
 | ||||
| /*
 | ||||
|  *	F O R M A T   E N U M E R A T I O N | ||||
|  */ | ||||
|  | @ -752,7 +756,16 @@ struct v4l2_framebuffer { | |||
| /* FIXME: in theory we should pass something like PCI device + memory
 | ||||
|  * region + offset instead of some physical address */ | ||||
| 	void                    *base; | ||||
| 	struct v4l2_pix_format	fmt; | ||||
| 	struct { | ||||
| 		__u32		width; | ||||
| 		__u32		height; | ||||
| 		__u32		pixelformat; | ||||
| 		__u32		field;		/* enum v4l2_field */ | ||||
| 		__u32		bytesperline;	/* for padding, zero if unused */ | ||||
| 		__u32		sizeimage; | ||||
| 		__u32		colorspace;	/* enum v4l2_colorspace */ | ||||
| 		__u32		priv;		/* reserved field, set to 0 */ | ||||
| 	} fmt; | ||||
| }; | ||||
| /*  Flags for the 'capability' field. Read only */ | ||||
| #define V4L2_FBUF_CAP_EXTERNOVERLAY	0x0001 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Laurent Pinchart
				Laurent Pinchart