kevin thayer <nufan_wfk@xxxxxxxxx> writes: > B) Request lots of additions to the spec, and wait for > the v4l gurus to hash out a standard > C) something else. Go ahead building something for the v4l2 API. I've recently fixed up some minor v4l2 API issues (diff below). The (currently unused) struct v4l2_compression and related ioctls can be recycled for the MPEG settings. I've added a long comment assembled from mails on this list there. As there are _lots_ of settings for MPEG1/2 it is probably a good idea to split the whole thing into some groups. Maybe this way: struct v4l2_compression { /* rename to mpeg_compression ??? */ unsigned int group; union { struct system { ... }; struct video { ... }; struct audio { ... }; }; }; Semantics of the S_COMP should be consistent with the other v4l2 S_* ioctls, i.e. the driver is allowed to change the parameters to match the hardware capabilities and the application has to check returned parameters to see if they fit the needs. Gerd ==============================[ cut here ]============================== diff -ur -X /home/kraxel/.kdontdiff linux-2003-03-15.orig/drivers/media/video/videodev.c linux-2003-03-15/drivers/media/video/videodev.c --- linux-2003-03-15.orig/drivers/media/video/videodev.c 2003-03-17 12:37:37.833156664 +0100 +++ linux-2003-03-15/drivers/media/video/videodev.c 2003-03-17 12:32:51.000000000 +0100 @@ -121,6 +121,15 @@ void *parg = NULL; int err = -EINVAL; + /* for compatibility, will go away some day */ + switch (cmd) { + case VIDIOC_OVERLAY_OLD: cmd = VIDIOC_OVERLAY; break; + case VIDIOC_S_PARM_OLD: cmd = VIDIOC_S_PARM; break; + case VIDIOC_S_CTRL_OLD: cmd = VIDIOC_S_CTRL; break; + case VIDIOC_G_AUDIO_OLD: cmd = VIDIOC_G_AUDIO; break; + case VIDIOC_G_AUDOUT_OLD: cmd = VIDIOC_G_AUDOUT; break; + } + /* Copy arguments into temp kernel buffer */ switch (_IOC_DIR(cmd)) { case _IOC_NONE: diff -ur -X /home/kraxel/.kdontdiff linux-2003-03-15.orig/include/linux/videodev2.h linux-2003-03-15/include/linux/videodev2.h --- linux-2003-03-15.orig/include/linux/videodev2.h 2003-03-17 12:38:21.411531744 +0100 +++ linux-2003-03-15/include/linux/videodev2.h 2003-03-17 13:00:46.860992336 +0100 @@ -13,7 +13,9 @@ * Justin Schoeman * et al. */ +#ifdef __KERNEL__ #include <linux/time.h> /* need struct timeval */ +#endif /* * M I S C E L L A N E O U S @@ -144,8 +146,9 @@ #define V4L2_CAP_VBI_OUTPUT 0x00000020 /* Is a VBI output device */ #define V4L2_CAP_RDS_CAPTURE 0x00000100 /* RDS data capture */ -#define V4L2_CAP_TUNER 0x00010000 /* Has a tuner */ +#define V4L2_CAP_TUNER 0x00010000 /* has a tuner */ #define V4L2_CAP_AUDIO 0x00020000 /* has audio support */ +#define V4L2_CAP_RADIO 0x00040000 /* is a radio device */ #define V4L2_CAP_READWRITE 0x01000000 /* read/write systemcalls */ #define V4L2_CAP_ASYNCIO 0x02000000 /* async I/O */ @@ -264,6 +267,51 @@ __u32 keyframerate; __u32 pframerate; __u32 reserved[5]; + +/* what we'll need for MPEG, extracted from some postings on + the v4l list (Gert Vervoort, PlasmaJohn). + +system stream: + - type: elementary stream(ES), packatised elementary stream(s) (PES) + program stream(PS), transport stream(TS) + - system bitrate + - PS packet size (DVD: 2048 bytes, VCD: 2324 bytes) + - TS video PID + - TS audio PID + - TS PCR PID + - TS system information tables (PAT, PMT, CAT, NIT and SIT) + - (MPEG-1 systems stream vs. MPEG-2 program stream (TS not supported + by MPEG-1 systems) + +audio: + - type: MPEG (+Layer I,II,III), AC-3, LPCM + - bitrate + - sampling frequency (DVD: 48 Khz, VCD: 44.1 KHz, 32 kHz) + - Trick Modes? (ff, rew) + - Copyright + - Inverse Telecine + +video: + - picturesize (SIF, 1/2 D1, 2/3 D1, D1) and PAL/NTSC norm can be set + through excisting V4L2 controls + - noise reduction, parameters encoder specific? + - MPEG video version: MPEG-1, MPEG-2 + - GOP (Group Of Pictures) definition: + - N: number of frames per GOP + - M: distance between reference (I,P) frames + - open/closed GOP + - quantiser matrix: inter Q matrix (64 bytes) and intra Q matrix (64 bytes) + - quantiser scale: linear or logarithmic + - scanning: alternate or zigzag + - bitrate mode: CBR (constant bitrate) or VBR (variable bitrate). + - target video bitrate for CBR + - target video bitrate for VBR + - maximum video bitrate for VBR - min. quantiser value for VBR + - max. quantiser value for VBR + - adaptive quantisation value + - return the number of bytes per GOP or bitrate for bitrate monitoring + +*/ }; #endif @@ -783,22 +831,22 @@ #define VIDIOC_QUERYBUF _IOWR ('V', 9, struct v4l2_buffer) #define VIDIOC_G_FBUF _IOR ('V', 10, struct v4l2_framebuffer) #define VIDIOC_S_FBUF _IOW ('V', 11, struct v4l2_framebuffer) -#define VIDIOC_OVERLAY _IOWR ('V', 14, int) +#define VIDIOC_OVERLAY _IOW ('V', 14, int) #define VIDIOC_QBUF _IOWR ('V', 15, struct v4l2_buffer) #define VIDIOC_DQBUF _IOWR ('V', 17, struct v4l2_buffer) #define VIDIOC_STREAMON _IOW ('V', 18, int) #define VIDIOC_STREAMOFF _IOW ('V', 19, int) #define VIDIOC_G_PARM _IOWR ('V', 21, struct v4l2_streamparm) -#define VIDIOC_S_PARM _IOW ('V', 22, struct v4l2_streamparm) +#define VIDIOC_S_PARM _IOWR ('V', 22, struct v4l2_streamparm) #define VIDIOC_G_STD _IOR ('V', 23, v4l2_std_id) #define VIDIOC_S_STD _IOW ('V', 24, v4l2_std_id) #define VIDIOC_ENUMSTD _IOWR ('V', 25, struct v4l2_standard) #define VIDIOC_ENUMINPUT _IOWR ('V', 26, struct v4l2_input) #define VIDIOC_G_CTRL _IOWR ('V', 27, struct v4l2_control) -#define VIDIOC_S_CTRL _IOW ('V', 28, struct v4l2_control) +#define VIDIOC_S_CTRL _IOWR ('V', 28, struct v4l2_control) #define VIDIOC_G_TUNER _IOWR ('V', 29, struct v4l2_tuner) #define VIDIOC_S_TUNER _IOW ('V', 30, struct v4l2_tuner) -#define VIDIOC_G_AUDIO _IOWR ('V', 33, struct v4l2_audio) +#define VIDIOC_G_AUDIO _IOR ('V', 33, struct v4l2_audio) #define VIDIOC_S_AUDIO _IOW ('V', 34, struct v4l2_audio) #define VIDIOC_QUERYCTRL _IOWR ('V', 36, struct v4l2_queryctrl) #define VIDIOC_QUERYMENU _IOWR ('V', 37, struct v4l2_querymenu) @@ -807,7 +855,7 @@ #define VIDIOC_G_OUTPUT _IOR ('V', 46, int) #define VIDIOC_S_OUTPUT _IOWR ('V', 47, int) #define VIDIOC_ENUMOUTPUT _IOWR ('V', 48, struct v4l2_output) -#define VIDIOC_G_AUDOUT _IOWR ('V', 49, struct v4l2_audioout) +#define VIDIOC_G_AUDOUT _IOR ('V', 49, struct v4l2_audioout) #define VIDIOC_S_AUDOUT _IOW ('V', 50, struct v4l2_audioout) #define VIDIOC_G_MODULATOR _IOWR ('V', 54, struct v4l2_modulator) #define VIDIOC_S_MODULATOR _IOW ('V', 55, struct v4l2_modulator) @@ -820,6 +868,15 @@ #define VIDIOC_S_JPEGCOMP _IOW ('V', 62, struct v4l2_jpegcompression) #define VIDIOC_QUERYSTD _IOR ('V', 63, v4l2_std_id) #define VIDIOC_TRY_FMT _IOWR ('V', 64, struct v4l2_format) +#define VIDIOC_ENUMAUDIO _IOWR ('V', 65, struct v4l2_audio) +#define VIDIOC_ENUMAUDOUT _IOWR ('V', 66, struct v4l2_audioout) + +/* for compatibility, will go away some day */ +#define VIDIOC_OVERLAY_OLD _IOWR ('V', 14, int) +#define VIDIOC_S_PARM_OLD _IOW ('V', 22, struct v4l2_streamparm) +#define VIDIOC_S_CTRL_OLD _IOW ('V', 28, struct v4l2_control) +#define VIDIOC_G_AUDIO_OLD _IOWR ('V', 33, struct v4l2_audio) +#define VIDIOC_G_AUDOUT_OLD _IOWR ('V', 49, struct v4l2_audioout) #define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */