ivtv-utils-1.4.1/0000775000076400007640000000000011355717714012340 5ustar andyandyivtv-utils-1.4.1/ChangeLog0000664000076400007640000000104411355717530014105 0ustar andyandyivtv utilities changes: 1.4.1 release: - Fix ps-analyzer SCR and Mux Rate decoding. patch submitted by Lars Hanisch 1.4.0 release: - Updated for kernel 2.6.29. - Fix and enhance ivtv private packet decoding. - Update to latest v4l2-ctl. - Removed v4l2-dbg: use the version from the official v4l-dvb repository instead. 1.3.0 release: - First release of the ivtv-utils package, renamed from the older ivtv releases. Note: ivtvctl has been renamed to ivtv-ctl. This makes it consistent with the naming of other v4l2 utilities. ivtv-utils-1.4.1/test/0000775000076400007640000000000011355717714013317 5ustar andyandyivtv-utils-1.4.1/test/mpeg-read-test.c0000664000076400007640000000516111355717527016306 0ustar andyandy/* open/read/close stress test Copyright (C) 2007 Hans Verkuil This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include int main(int argc, char **argv) { char *device = "/dev/video0"; unsigned cnt = 0; unsigned bufsz; unsigned char buf[2048 * 1024]; int fh, sz, i; time_t t; if (argc > 1) device = argv[1]; srand(time(NULL)); for (;;) { for (bufsz = 4; bufsz <= 2048 * 1024; bufsz *= 2) { for (i = 0; i < 8; i++) { cnt++; fh = open(device, O_RDONLY); printf("%06u/%d/%07u: ", cnt, i, bufsz); if (fh == -1) { fprintf(stderr, "cannot open %s\n", device); return -1; } if ((sz = read(fh, buf, bufsz)) != bufsz) { printf("read %d, expected %u\n", sz, bufsz); ioctl(fh, VIDIOC_LOG_STATUS, 0); return -1; } if (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) { printf("garbage at start of buffer (%02x %02x %02x)\n", buf[0], buf[1], buf[2]); //ioctl(fh, VIDIOC_LOG_STATUS, 0); return -1; } else { t = time(NULL); printf("%s", ctime(&t)); } close(fh); } } for (i = 0; i < 80; i++) { bufsz = (rand() % sizeof(buf)) + 1; if (bufsz < 3) bufsz = 3; cnt++; fh = open(device, O_RDONLY); printf("%06u/%d/%07u: ", cnt, i, bufsz); if (fh == -1) { fprintf(stderr, "cannot open %s\n", device); return -1; } if ((sz = read(fh, buf, bufsz)) != bufsz) { printf("read %d, expected %u\n", sz, bufsz); ioctl(fh, VIDIOC_LOG_STATUS, 0); return -1; } if (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) { printf("garbage at start of buffer (%02x %02x %02x)\n", buf[0], buf[1], buf[2]); //ioctl(fh, VIDIOC_LOG_STATUS, 0); return -1; } else { t = time(NULL); printf("%s", ctime(&t)); } close(fh); } } return 0; } ivtv-utils-1.4.1/test/mpeg-enc-stop-start-test.c0000664000076400007640000000332011355717527020251 0ustar andyandy/* open/read/close stress test Copyright (C) 2007 Hans Verkuil This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include int main(int argc, char **argv) { char *device = "/dev/video0"; unsigned char buf[256 * 1024]; struct v4l2_encoder_cmd cmd; int fh; int sz; int i; if (argc > 1) device = argv[1]; fh = open(device, O_RDONLY); if (fh == -1) { fprintf(stderr, "cannot open %s\n", device); return -1; } for (;;) { for (i = 0; i < 10; i++) { if ((sz = read(fh, buf, sizeof(buf))) <= 0) { fprintf(stderr, "read %d, expected %u\n", sz, sizeof(buf)); ioctl(fh, VIDIOC_LOG_STATUS, 0); return -1; } write(1, buf, sizeof(buf)); } cmd.cmd = V4L2_ENC_CMD_STOP; cmd.flags = 0; ioctl(fh, VIDIOC_ENCODER_CMD, &cmd); sleep(1); cmd.cmd = V4L2_ENC_CMD_START; cmd.flags = 0; ioctl(fh, VIDIOC_ENCODER_CMD, &cmd); } return 0; } ivtv-utils-1.4.1/test/ivtv-fb-colormap-test.c0000664000076400007640000000337411355717527017640 0ustar andyandy#include #include #include #include #include #include #include #include #include #include #define W 720 #define H 576 #define IDX 0xff static unsigned char osd[720*576]; int main(int argc, char **argv) { char *device = "/dev/fb0"; __u16 red[256], green[256], blue[256], transp[256]; struct fb_cmap cmap; struct fb_var_screeninfo vi; struct ivtvfb_dma_frame df; int fd; int i; if (argc > 1) device = argv[1]; fd = open(device, O_RDWR); if (fd == -1) { fprintf(stderr, "cannot open %s\n", device); exit(-1); } ioctl(fd, FBIOGET_VSCREENINFO, &vi); vi.nonstd = 0; vi.bits_per_pixel = 8; vi.xres = W; vi.yres = H; vi.xres_virtual = W; vi.yres_virtual = H; vi.xoffset = 0; vi.yoffset = 0; ioctl(fd, FBIOPUT_VSCREENINFO, &vi); cmap.red = red; cmap.green = green; cmap.blue = blue; cmap.transp = transp; cmap.start = 0; cmap.len = 256; ioctl(fd, FBIOGETCMAP, &cmap); printf("Ind: AA RR GG BB\n"); for (i = 0; i < cmap.len; i++) { printf("%3d: %02x %02x %02x %02x\n", i, cmap.transp[i] >> 8, cmap.red[i] >> 8, cmap.green[i] >> 8, cmap.blue[i] >> 8); } memset(osd, IDX, sizeof(osd)); df.source = osd; df.dest_offset = 0; df.count = sizeof(osd); ioctl(fd, IVTVFB_IOC_DMA_FRAME, &df); cmap.transp[IDX] = 0xffff; // go from black to white (opaque) for (i = 0; i < 256; i++) { cmap.red[IDX] = i << 8; cmap.blue[IDX] = i << 8; cmap.green[IDX] = i << 8; ioctl(fd, FBIOPUTCMAP, &cmap); ioctl(fd, FBIO_WAITFORVSYNC, 0); } // go from opaque to transparent for (i = 255; i >= 0; i--) { cmap.transp[IDX] = i << 8; ioctl(fd, FBIOPUTCMAP, &cmap); ioctl(fd, FBIO_WAITFORVSYNC, 0); } return 0; } ivtv-utils-1.4.1/test/wss.c0000664000076400007640000000423511355717527014305 0ustar andyandy/* Widescreen output mode demonstration utility Copyright (C) 2004 Hans Verkuil This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include /* Uses _GNU_SOURCE to define getsubopt in stdlib.h */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include int main(int argc, char **argv) { char *device = "/dev/vbi16"; struct v4l2_format fmt; struct v4l2_sliced_vbi_data *buf; int wss; int fh; if (argc <= 1) { fprintf(stderr, "usage: %s 0|1 [vbi device]\n", argv[0]); exit(1); } wss = 8 + (atol(argv[1]) ? 3 : 0); if (argc == 3) device = argv[2]; fh = open(device, O_WRONLY); if (fh == -1) { fprintf(stderr, "cannot open %s\n", device); return 1; } fmt.fmt.sliced.service_set = V4L2_SLICED_WSS_625; fmt.type = V4L2_BUF_TYPE_SLICED_VBI_OUTPUT; if (ioctl(fh, VIDIOC_S_FMT, &fmt) == -1) { fprintf(stderr, "Set VBI mode failed\n"); exit(1); } ioctl(fh, VIDIOC_G_FMT, &fmt); printf("%08x, %d\n", fmt.fmt.sliced.service_set, fmt.fmt.sliced.io_size); buf = malloc(fmt.fmt.sliced.io_size); buf[0].id = V4L2_SLICED_WSS_625; buf[0].line = 23; buf[0].field = 0; buf[0].data[0] = wss; buf[0].data[1] = 0; write(fh, buf, sizeof(buf[0])); close(fh); return 0; } ivtv-utils-1.4.1/test/ivtv-fb-16-bit-test.c0000664000076400007640000000615011355717527017021 0ustar andyandy#include #include #include #include #include #include #include #include #include #include #define W 720 #define H 576 static unsigned short osd[720*576]; int main(int argc, char **argv) { char *device = "/dev/fb0"; struct fb_var_screeninfo vi; struct ivtvfb_dma_frame df; int fd; int i, j; if (argc > 1) device = argv[1]; fd = open(device, O_RDWR); if (fd == -1) { fprintf(stderr, "cannot open %s\n", device); exit(-1); } ioctl(fd, FBIOGET_VSCREENINFO, &vi); vi.nonstd = 0; vi.bits_per_pixel = 16; vi.red.offset = 8; vi.red.length = 4; vi.green.offset = 4; vi.green.length = 4; vi.blue.offset = 0; vi.blue.length = 4; vi.transp.offset = 12; vi.transp.length = 1; vi.xres = W; vi.yres = H; vi.xres_virtual = W; vi.yres_virtual = H; vi.xoffset = 0; vi.yoffset = 0; ioctl(fd, FBIOPUT_VSCREENINFO, &vi); memset(osd, 0, sizeof(osd)); df.source = osd; df.dest_offset = 0; df.count = sizeof(osd); ioctl(fd, IVTVFB_IOC_DMA_FRAME, &df); // go from black to white (opaque) for (i = 0; i < 16; i++) { for (j = 0; j < sizeof(osd) / 2; j++) osd[j] = i | (i << 4) | (i << 8); ioctl(fd, IVTVFB_IOC_DMA_FRAME, &df); ioctl(fd, FBIO_WAITFORVSYNC, 0); ioctl(fd, FBIO_WAITFORVSYNC, 0); ioctl(fd, FBIO_WAITFORVSYNC, 0); ioctl(fd, FBIO_WAITFORVSYNC, 0); } // go from opaque to transparent for (j = 0; j < sizeof(osd) / 2; j++) osd[j] |= (1 << 12); ioctl(fd, IVTVFB_IOC_DMA_FRAME, &df); sleep(1); ioctl(fd, FBIOGET_VSCREENINFO, &vi); vi.red.offset = 10; vi.red.length = 5; vi.green.offset = 5; vi.green.length = 5; vi.blue.offset = 0; vi.blue.length = 5; vi.transp.offset = 15; vi.transp.length = 1; ioctl(fd, FBIOPUT_VSCREENINFO, &vi); memset(osd, 0, sizeof(osd)); df.source = osd; df.dest_offset = 0; df.count = sizeof(osd); ioctl(fd, IVTVFB_IOC_DMA_FRAME, &df); // go from black to white (opaque) for (i = 0; i < 32; i++) { for (j = 0; j < sizeof(osd) / 2; j++) osd[j] = i | (i << 5) | (i << 10); ioctl(fd, IVTVFB_IOC_DMA_FRAME, &df); ioctl(fd, FBIO_WAITFORVSYNC, 0); ioctl(fd, FBIO_WAITFORVSYNC, 0); ioctl(fd, FBIO_WAITFORVSYNC, 0); ioctl(fd, FBIO_WAITFORVSYNC, 0); } // go from opaque to transparent for (j = 0; j < sizeof(osd) / 2; j++) osd[j] |= (1 << 15); ioctl(fd, IVTVFB_IOC_DMA_FRAME, &df); sleep(1); ioctl(fd, FBIOGET_VSCREENINFO, &vi); vi.nonstd = 1; vi.red.offset = 11; vi.red.length = 5; vi.green.offset = 5; vi.green.length = 6; vi.blue.offset = 0; vi.blue.length = 5; vi.transp.offset = 0; vi.transp.length = 0; ioctl(fd, FBIOPUT_VSCREENINFO, &vi); memset(osd, 0, sizeof(osd)); df.source = osd; df.dest_offset = 0; df.count = sizeof(osd); ioctl(fd, IVTVFB_IOC_DMA_FRAME, &df); // go from black to white (opaque) for (i = 0; i < 32; i++) { for (j = 0; j < sizeof(osd) / 2; j++) osd[j] = i | (i << 6) | (i << 11); ioctl(fd, IVTVFB_IOC_DMA_FRAME, &df); ioctl(fd, FBIO_WAITFORVSYNC, 0); ioctl(fd, FBIO_WAITFORVSYNC, 0); ioctl(fd, FBIO_WAITFORVSYNC, 0); ioctl(fd, FBIO_WAITFORVSYNC, 0); } return 0; } ivtv-utils-1.4.1/test/mpeg-read-sleep-test.c0000664000076400007640000000273011355717527017413 0ustar andyandy/* read/sleep stress test Copyright (C) 2007 Hans Verkuil This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include int main(int argc, char **argv) { char *device = "/dev/video0"; unsigned char buf[256 * 1024]; int fh; int sz; if (argc > 1) device = argv[1]; fh = open(device, O_RDONLY); if (fh == -1) { fprintf(stderr, "cannot open %s\n", device); return -1; } for (;;) { if ((sz = read(fh, buf, sizeof(buf))) != sizeof(buf)) { fprintf(stderr, "read %d, expected %u\n", sz, sizeof(buf)); ioctl(fh, VIDIOC_LOG_STATUS, 0); return -1; } write(1, buf, sizeof(buf)); sleep(1); } return 0; } ivtv-utils-1.4.1/test/vbi-detect.c0000664000076400007640000001070211355717527015513 0ustar andyandy/* Sliced vbi autodetection demonstration utility Copyright (C) 2004 Hans Verkuil This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include /* Uses _GNU_SOURCE to define getsubopt in stdlib.h */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void detect(int fh, struct v4l2_sliced_vbi_format *fmt) { struct v4l2_sliced_vbi_data *buf = malloc(fmt->io_size); int cnt; for (cnt = 0; cnt < 5; cnt++) { int size = read(fh, buf, fmt->io_size); int i; if (size <= 0) { printf("size = %d\n", size); break; } if (cnt == 0) continue; for (i = 0; i < size / sizeof(*buf); i++) { int field, line; line = buf[i].line; field = buf[i].field; if (buf[i].id == 0) continue; if (line < 0 || line >= 24) { printf("line %d out of range\n", line); free(buf); return; } fmt->service_lines[field][line] |= buf[i].id; } } free(buf); } void v2s(int id) { switch (id) { case V4L2_SLICED_TELETEXT_B: printf(" TELETEXT"); break; case V4L2_SLICED_CAPTION_525: printf(" CC"); break; case V4L2_SLICED_WSS_625: printf(" WSS"); break; case V4L2_SLICED_VPS: printf(" VPS"); break; default: printf(" UNKNOWN %x", id); break; } } int main(int argc, char **argv) { char *device = "/dev/vbi0"; struct v4l2_format vbifmt; struct v4l2_sliced_vbi_format vbiresult; int fh; int f, i, b; if (argc == 2) device = argv[1]; fh = open(device, O_RDONLY); if (fh == -1) { fprintf(stderr, "cannot open %s\n", device); return 1; } memset(&vbiresult, 0, sizeof(vbiresult)); for (i = 0; i < 16; i++) { int l; int set = 0; memset(&vbifmt, 0, sizeof(vbifmt)); vbifmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE; for (l = 0; l < 24; l++) { vbifmt.fmt.sliced.service_lines[0][l] = 1 << i; vbifmt.fmt.sliced.service_lines[1][l] = 1 << i; } if (ioctl(fh, VIDIOC_S_FMT, &vbifmt) < 0) { if (errno == EINVAL) continue; perror("IVTV_IOC_S_VBI_FMT"); exit(-1); } vbiresult.io_size = vbifmt.fmt.sliced.io_size; for (l = 0; l < 24; l++) { set |= vbifmt.fmt.sliced.service_lines[0][l] | vbifmt.fmt.sliced.service_lines[1][l]; } detect(fh, &vbiresult); } close(fh); for (f = 0; f < 2; f++) { printf("Field %d:\n", f); for (i = 6; i < 24; i++) { unsigned set = vbiresult.service_lines[f][i]; printf(" Line %2d:", i); for (b = 0; b < 16; b++) { if (set & (1 << b)) v2s(1 << b); } printf("\n"); } } return 0; } ivtv-utils-1.4.1/test/mpeg-freq-test.c0000664000076400007640000000317511355717527016333 0ustar andyandy/* Frequency change stress test Copyright (C) 2007 Hans Verkuil This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include int main(int argc, char **argv) { char *device = "/dev/video0"; unsigned cnt = 0; int fh; time_t t; //double f[2] = { 479.25, 503.25 }; double f[2] = { 147.25, 154.25 }; if (argc > 1) device = argv[1]; fh = open(device, O_RDONLY); if (fh == -1) { fprintf(stderr, "cannot open %s\n", device); return -1; } for (;;) { struct v4l2_frequency vf; int err; cnt++; vf.tuner = 0; vf.type = V4L2_TUNER_ANALOG_TV; vf.frequency = f[cnt % 2] * 16; t = time(NULL); printf("%06u: %.2f %s", cnt, f[cnt % 2], ctime(&t)); if ((err = ioctl(fh, VIDIOC_S_FREQUENCY, &vf))) { perror("could not set frequency"); return -1; } } return 0; } ivtv-utils-1.4.1/test/ps-analyzer.cpp0000664000076400007640000002000411355717527016266 0ustar andyandy/* # # MPEG2Parser class testing tool # # Copyright (C) 2001-2003 Kees Cook # kees@outflux.net, http://outflux.net/ # # Sliced VBI decoding and conversion of scr, pts and dts to seconds is ... # Copyright (C) 2009 Andy Walls # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # http://www.gnu.org/copyleft/gpl.html # */ /* * buffer management inspired by mplayer */ #define _FILE_OFFSET_BITS 64 #include #include #include #include #include #include #include #include #include #include #include #include #include #include "mpeg2structs.h" typedef unsigned long long u64; typedef unsigned int u32; typedef unsigned short u16; typedef unsigned char u8; static u32 g_vid_count; static u32 g_aud_count; static u32 g_vbi_count; static u64 g_first_vid_pts; static u64 g_last_vid_pts; static int g_verbose; static void statistics() { printf("\nStatistics:\n\n"); printf("video frames: %u\n", g_vid_count); printf("audio frames: %u\n", g_aud_count); printf("private packets: %u\n", g_vbi_count); printf("total time: %.2f seconds\n", (g_last_vid_pts - g_first_vid_pts) / 90000.0); } static void psread(int fh, void *buf, int cnt, bool valid_eof = false) { int res = read(fh, buf, cnt); if (res == cnt) return; if (res == 0 && valid_eof) fprintf(stderr, "end of file\n"); else fprintf(stderr, "broken stream\n"); statistics(); exit(1); } static unsigned psread_u32(int fh, bool valid_eof = false) { unsigned char buf[4]; psread(fh, buf, 4, valid_eof); return (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; } static unsigned short psread_u16(int fh, bool valid_eof = false) { unsigned char buf[2]; psread(fh, buf, 2, valid_eof); return (buf[0] << 8) | buf[1]; } static const char *vbi_line_id(u8 id) { const char *ret; switch (id) { case V4L2_MPEG_VBI_IVTV_TELETEXT_B: ret = "Teletext B"; break; case V4L2_MPEG_VBI_IVTV_CAPTION_525: ret = "Closed Caption (525 line system)"; break; case V4L2_MPEG_VBI_IVTV_WSS_625: ret = "Wide Screen Signalling (625 line system)"; break; case V4L2_MPEG_VBI_IVTV_VPS: ret = "Video Programming System"; break; default: ret = "unknown"; break; } return ret; } static void vbi_decode(u8 *buf, int length) { struct v4l2_mpeg_vbi_fmt_ivtv *vbi; u32 linemask[2]; struct v4l2_mpeg_vbi_itv0_line *line; int i, f, l; vbi = (struct v4l2_mpeg_vbi_fmt_ivtv *) buf; if (!memcmp(vbi->magic, V4L2_MPEG_VBI_IVTV_MAGIC1, sizeof(vbi->magic))) { printf("36 lines:\n"); line = vbi->ITV0.line; /* This only works for little endian machines */ linemask[0] = 0xffffffff; linemask[1] = 0x0000000f; } else if (!memcmp(vbi->magic, V4L2_MPEG_VBI_IVTV_MAGIC0, sizeof(vbi->magic))) { printf("<36 lines:\n"); line = vbi->itv0.line; /* This only works for little endian machines */ linemask[0] = vbi->itv0.linemask[0]; linemask[1] = vbi->itv0.linemask[1]; } else { printf("unknown "); return; } i = 0; for (f = 1; f <= 2; f++) { for (l = 6; l <= 23; l++) { if (linemask[0] & 1) { printf("\t\tfield %d, line %2d: %s\n", f, l, vbi_line_id(line[i].id)); i++; } linemask[0] >>= 1; } linemask[0] |= (linemask[1] << (32 - (23-6+1))); linemask[1] = 0; } printf("\t\t"); return; } static u64 scr2ns(u64 scr, unsigned scr_ext) { return (300 * scr + scr_ext) * 1000 / 27; } static u64 xts2us(u64 xts) { return (100 * xts) / 9; } static void pack_header(int fh, u64 pos) { unsigned char hdr[10]; unsigned marker; u64 scr; unsigned scr_ext; unsigned mux_rate; psread(fh, hdr, 10); lseek64(fh, hdr[9] & 3, SEEK_CUR); // Skip stuffing bytes scr = (u64)(hdr[0] & 0x38) << 27; scr |= (u64)(hdr[0] & 3) << 28; scr |= (u64)hdr[1] << 20; scr |= (u64)(hdr[2] & 0xf8) << 12; scr |= (u64)(hdr[2] & 3) << 13; scr |= (u64)hdr[3] << 5; scr |= (u64)(hdr[4] & 0xf8) >> 3; scr_ext = (unsigned)(hdr[4] & 0x3) << 7; scr_ext |= (hdr[5] & 0xfe) >> 1; mux_rate = (unsigned)(hdr[6]) << 14; mux_rate |= (unsigned)(hdr[7]) << 6; mux_rate |= (unsigned)(hdr[8] & 0xfc) >> 2; if (g_verbose) printf("%lld: pack scr=%lld scr_ext=%3u scr=%lld ns mux_rate=%u\n", pos, scr, scr_ext, scr2ns(scr, scr_ext), mux_rate); marker = psread_u32(fh); if (marker != 0x000001bb) { lseek64(fh, -4, SEEK_CUR); return; } // System header unsigned short length = psread_u16(fh); if (g_verbose) printf("\tSystem header\n"); lseek64(fh, length, SEEK_CUR); } static void pes_packet(int fh, int code, u16 length, u64 pos) { if (code == 0xbe) { if (g_verbose) printf("\t%lld: Padding length=%d\n", pos, length); return; } if (code == 0xbf) { printf("\t%lld: Navigation packet length=%d\n", pos, length); return; } if (code != 0xbd && code != 0xc0 && code != 0xe0) { printf("\t%lld: Unknown packet %02x\n", pos, code); return; } unsigned char hdr[13]; u64 pts = 0; u64 dts = 0; psread(fh, hdr, 3); /* flags, flags, PES header data length */ psread(fh, &(hdr[3]), hdr[2]); if (hdr[1] & 0x80) { pts = (u64)(hdr[3] & 0xe) << 29; pts |= (u64)(hdr[4]) << 22; pts |= (u64)(hdr[5] & 0xfe) << 14; pts |= (u64)(hdr[6]) << 7; pts |= (u64)(hdr[7]) >> 1; } if (hdr[1] & 0x40) { dts = (u64)(hdr[8] & 0xe) << 29; dts |= (u64)(hdr[9]) << 22; dts |= (u64)(hdr[10] & 0xfe) << 14; dts |= (u64)(hdr[11]) << 7; dts |= (u64)(hdr[12]) >> 1; } if (pts == 0) return; if (code == 0xc0) { printf("\t%lld: Audio ", pos); g_aud_count++; } else if (code == 0xbd) { u8 buf[2048]; u16 remaining = length - (3 + hdr[2]); printf("\t%lld: Private Packet ", pos); if (remaining <= sizeof(buf)) { psread(fh, buf, remaining); vbi_decode(buf, remaining); } g_vbi_count++; } else { printf("\t%lld: Video ", pos); if (g_vid_count++ == 0) g_first_vid_pts = pts; g_last_vid_pts = pts; } if (dts) printf("pts=%llu (%llu us) dts=%llu (%llu us) length=%d\n", pts, xts2us(pts), dts, xts2us(dts), length); else printf("pts=%llu (%lld us) length=%d\n", pts, xts2us(pts), length); } int main(int argc, char *argv[]) { int fh; int opt; u64 pos = 0; u64 len; for (;;) { opt = getopt(argc, argv, "vh"); if (opt == -1) break; switch (opt) { case 'v': g_verbose = 1; break; case 'h': printf("usage: %s [-v] [-h] mpeg-file\n", argv[0]); printf("-v: verbose output\n"); printf("-h: this help message\n"); exit(0); } } if (optind != argc - 1) { printf("usage: %s [-v] [-h] mpeg-file\n", argv[0]); printf("-v: verbose output\n"); printf("-h: this help message\n"); return -1; } fh = open(argv[optind], O_RDONLY); if (fh < 0) { fprintf(stderr, "%s: cannot open mpeg file %s\n", argv[0], argv[optind]); return -2; } len = lseek64(fh, 0, SEEK_END); while (1) { lseek64(fh, pos, SEEK_SET); u32 marker = psread_u32(fh); if (marker != 0x000001ba) { if (marker == 0x000001b9) { // PS end marker printf("\t%lld: End marker\n", pos); break; } fprintf(stderr, "missing pack marker (got %08x @ %lld)\n", marker, pos); break; } pack_header(fh, pos); while (1) { pos = lseek64(fh, 0, SEEK_CUR); marker = psread_u32(fh, pos == len); if (marker == 0x000001ba || marker == 0x000001b9) break; u16 length = psread_u16(fh); pes_packet(fh, marker & 0xff, length, pos); pos += length + 6; lseek64(fh, pos, SEEK_SET); } } close(fh); statistics(); return 0; } ivtv-utils-1.4.1/test/ivtv-yuv-dma-test.c0000664000076400007640000000176511355717527017023 0ustar andyandy#include #include #include #include #include #include #include #include #define W 720 #define H 576 static unsigned char frame[W*H*3/2]; /*************************************************************************/ int main(int argc, char **argv) { char *device = "/dev/video16"; FILE *fin; int fd; struct ivtv_dma_frame df; if (argc > 1) device = argv[1]; fin = stdin; fd = open(device, O_RDWR); if (fd == -1) { fprintf(stderr, "cannot open %s\n", device); exit(-1); } memset(&df, 0, sizeof(df)); while (fread(frame, 1, sizeof(frame), fin)) { df.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; df.y_source = frame; df.uv_source = frame + W*H; df.src.top = df.src.left = 0; df.src.height = H; df.src.width = W; df.dst.top = df.dst.left = 0; df.dst.height = H; df.dst.width = W; df.src_height = H; df.src_width = W; ioctl(fd, IVTV_IOC_DMA_FRAME, &df); } fclose(fin); return 0; } ivtv-utils-1.4.1/test/README0000664000076400007640000000276411355717527014212 0ustar andyandyThis directory contains a few utilities that are mainly used as test tools for the developers. However they can also be used as example code on how to handle sliced VBI (the main focus of these tools). Here is a short description of the available tools: fwapi: fwapi [-enc|-dec] -mbox_put N -cmd DDD -data1 DDD -data2 DDD -data3 DDD -data4 DDD Executes a firmware mailbox command. For internal testing only. vbi-detect: vbi-detect [vbi-device] Autodetects the available VBI services on the selected channel. The default vbi device is /dev/vbi0. If you want to use sliced VBI in your own code but still want to dynamically detect the available services then this code is a good starting point. vbi-passthrough: vbi-passthrough [vbi in device] [vbi out device] Example code that reads sliced VBI from the VBI-in device and writes it to the VBI-out device (by default /dev/vbi0 and /dev/vbi16). Usually you will embed VBI data in the mpeg stream and let the driver write it to TV-out, but this is an other option. vbi: vbi [vbi-device] Reads the sliced VBI data from the given VBI device (by default /dev/vbi0) and parses it. Heavily used for testing the sliced VBI data streams. A good source for example code on how to use sliced VBI. wss: wss 0|1 [vbi device] Simple tool to force TV-out to 4:3 ratio (0) or 16:9 ratio (1). The default vbi device is /dev/vbi16. PAL only. Usually you will embed the WSS data in the mpeg stream and let the driver write it to TV-out, but this is an other option. ivtv-utils-1.4.1/test/ivtv-osd-dma-test.c0000664000076400007640000000572611355717527016766 0ustar andyandy#include #include #include #include #include #include #include #include #include #define W 720 #define H 576 static unsigned char frame[720*576*3/2]; static unsigned char framey[W*H]; static unsigned char frameu[W*H / 4]; static unsigned char framev[W*H / 4]; static unsigned int osd[720*576]; static void de_macro_y(unsigned char* dst, unsigned char *src, int dstride, int w, int h) { unsigned int y, x, i; // descramble Y plane // dstride = 720 = w // The Y plane is divided into blocks of 16x16 pixels // Each block in transmitted in turn, line-by-line. for (y = 0; y < h; y += 16) { for (x = 0; x < w; x += 16) { for (i = 0; i < 16; i++) { memcpy(dst + x + (y + i) * dstride, src, 16); src += 16; } } } } static void de_macro_uv(unsigned char *dstu, unsigned char *dstv, unsigned char *src, int dstride, int w, int h) { unsigned int y, x, i; // descramble U/V plane // dstride = 720 / 2 = w // The U/V values are interlaced (UVUV...). // Again, the UV plane is divided into blocks of 16x16 UV values. // Each block in transmitted in turn, line-by-line. for (y = 0; y < h; y += 16) { for (x = 0; x < w; x += 8) { for (i = 0; i < 16; i++) { int idx = x + (y + i) * dstride; dstu[idx+0] = src[0]; dstv[idx+0] = src[1]; dstu[idx+1] = src[2]; dstv[idx+1] = src[3]; dstu[idx+2] = src[4]; dstv[idx+2] = src[5]; dstu[idx+3] = src[6]; dstv[idx+3] = src[7]; dstu[idx+4] = src[8]; dstv[idx+4] = src[9]; dstu[idx+5] = src[10]; dstv[idx+5] = src[11]; dstu[idx+6] = src[12]; dstv[idx+6] = src[13]; dstu[idx+7] = src[14]; dstv[idx+7] = src[15]; src += 16; } } } } /*************************************************************************/ int main(int argc, char **argv) { char *device = "/dev/fb0"; FILE *fin; int fd; int x, y; struct ivtvfb_dma_frame df; struct fb_var_screeninfo vi; if (argc > 1) device = argv[1]; fin = stdin; fd = open(device, O_RDWR); if (fd == -1) { fprintf(stderr, "cannot open %s\n", device); exit(-1); } ioctl(fd, FBIOGET_VSCREENINFO, &vi); vi.nonstd = 1; vi.bits_per_pixel = 32; vi.xres = W; vi.yres = H; vi.xres_virtual = W; vi.yres_virtual = H; vi.xoffset = 0; vi.yoffset = 0; ioctl(fd, FBIOPUT_VSCREENINFO, &vi); while (fread(frame, 1, sizeof(frame), fin)) { de_macro_y(framey, frame, W, W, H); de_macro_uv(frameu, framev, frame + 720 * H, W / 2, W / 2, H / 2); for (y = 0; y < H; y++) { for (x = 0; x < W; x++) { int y2 = y*2; int x2 = x * 2; if (x < W / 2 && y < H / 2) osd[y * W + x] = (framey[y2 * W + x2] << 16) | (frameu[(y2/2) * (W/2) + x2/2] << 8) | (framev[(y2/2) * (W/2) + x2/2]) | 0x8f000000; else osd[y * W + x] = 0x00000000; } } df.source = osd; df.dest_offset = 0; df.count = sizeof(osd); ioctl(fd, IVTVFB_IOC_DMA_FRAME, &df); } fclose(fin); return 0; } ivtv-utils-1.4.1/test/vbi-passthrough.c0000664000076400007640000000460711355717527016621 0ustar andyandy/* Sliced vbi passthrough demonstration utility Copyright (C) 2004 Hans Verkuil This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include /* Uses _GNU_SOURCE to define getsubopt in stdlib.h */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include int main(int argc, char **argv) { char *dev_in = "/dev/vbi0"; char *dev_out = "/dev/vbi16"; struct v4l2_format fmt; struct v4l2_sliced_vbi_data *buf; int len; int fin; int fout; if (argc <= 1) { fprintf(stderr, "usage: %s [vbi in device] [vbi out device]\n", argv[0]); exit(1); } if (argc >= 2) dev_in = argv[1]; if (argc == 3) dev_out = argv[2]; fin = open(dev_in, O_RDONLY); fout = open(dev_out, O_WRONLY); if (fin == -1) { fprintf(stderr, "cannot open %s\n", dev_in); return 1; } if (fout == -1) { fprintf(stderr, "cannot open %s\n", dev_out); return 1; } fmt.fmt.sliced.service_set = V4L2_SLICED_VBI_525 | V4L2_SLICED_VBI_625; fmt.fmt.sliced.reserved[0] = 0; fmt.fmt.sliced.reserved[1] = 0; fmt.type = V4L2_BUF_TYPE_SLICED_VBI_OUTPUT; ioctl(fout, VIDIOC_S_FMT, &fmt); fmt.fmt.sliced.service_set = V4L2_SLICED_VBI_525 | V4L2_SLICED_VBI_625; fmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE; ioctl(fin, VIDIOC_S_FMT, &fmt); buf = malloc(fmt.fmt.sliced.io_size); while ((len = read(fin, buf, fmt.fmt.sliced.io_size)) > 0) { if (write(fout, buf, len) != len) { break; } } close(fin); close(fout); return 0; } ivtv-utils-1.4.1/test/Makefile0000664000076400007640000000066011355717527014763 0ustar andyandyINSTALLDIR = /usr/local/bin HEADERDIR = /usr/include/linux EXES = vbi wss vbi-passthrough vbi-detect ivtv-pcm-tester \ mpeg-read-test mpeg-freq-test mpeg-read-sleep-test \ mpeg-enc-stop-start-test ivtv-yuv-dma-test \ ivtv-osd-dma-test ivtv-fb-colormap-test \ ivtv-fb-16-bit-test ps-analyzer CFLAGS = -I../utils -D_GNU_SOURCE -O2 -Wall CXXFLAGS = $(CFLAGS) LDFLAGS = -lm all: $(EXES) install: all clean: rm -f *.o $(EXES) ivtv-utils-1.4.1/test/ivtv-pcm-tester.c0000664000076400007640000000657511355717527016553 0ustar andyandy/* # # ivtv PCM output level/sample.freq diagnostic tool # # Copyright (C) 2006 Maksym Veremeyenko (verem@m1stereo.tv) # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # http://www.gnu.org/copyleft/gpl.html # */ #include #include /* Uses _GNU_SOURCE to define getsubopt in stdlib.h */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define SAMPLES_CNT (48000 / 10) #define DB_MAX 50 union { char bytes[4]; struct { long left:16; long right:16; } words; } __attribute__((packed)) audio_sample; void print_usage(void) { printf("Usage:\n\tivtv-pcm-tester \n"); }; int main(int argc, char **argv) { int fd; int i; char line[DB_MAX + 1]; line[DB_MAX] = 0; if (argc != 2) { fprintf(stderr, "Error, incorrect arguments!\n"); print_usage(); exit(-1); } fd = open(argv[1], O_RDONLY); if (fd == -1) { fprintf(stderr, "Error, unable to open device '%s'\n", argv[1]); exit(-1); } printf(" -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0\n" " Freq Level|....|....|....|....|....|....|....|....|....|....|!\n"); while (1) { struct timeval t1, t2; double peakl_max = 0.0, peakl_min = 65536.0; double peakr_max = 0.0, peakr_min = 65536.0; double period, f; /* fix time */ gettimeofday(&t1, NULL); /* read samples and find peaks */ for (i = 0; i < SAMPLES_CNT; i++) { /* read sample */ if (read(fd, &audio_sample, sizeof(audio_sample))) { double current = (double)audio_sample.words.left; if (peakl_max < current) peakl_max = current; if (peakl_min > current) peakl_min = current; current = (double)audio_sample.words.right; if (peakr_max < current) peakr_max = current; if (peakr_min > current) peakr_min = current; } else { printf("\n"); close(fd); exit(0); } } /* fix time */ gettimeofday(&t2, NULL); /* calc time */ period = (double)(t2.tv_sec - t1.tv_sec) + (double)(t2.tv_usec - t1.tv_usec) / 1000000.0; /* calc freq */ f = (period == 0.0) ? 0 : ((double)SAMPLES_CNT) / period; /* calc level */ double l = 20.0 * log((peakl_max - peakl_min) / 65536.0) / log(10.0); double r = 20.0 * log((peakr_max - peakr_min) / 65536.0) / log(10.0); /* create line */ for (i = 0; i < DB_MAX; i++) { line[i] = ' '; if (i - DB_MAX < l && i - DB_MAX < r) line[i] = '='; else if (i - DB_MAX < l) line[i] = 'l'; else if (i - DB_MAX < r) line[i] = 'r'; } /* output result */ printf("|%7.0lf| %7.3lf|%s\r", f, l, line); fflush(stdout); } } ivtv-utils-1.4.1/test/vbi.c0000664000076400007640000004124511355717527014253 0ustar andyandy/* Sliced vbi demonstration utility Copyright (C) 2004 Hans Verkuil This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include /* Uses _GNU_SOURCE to define getsubopt in stdlib.h */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define I2C_DRIVERID_CX25840 71 /* cx2584x video encoder */ #define I2C_DRIVERID_SAA711X 73 /* saa711x video encoders */ #define I2C_DRIVERID_SAA717X 80 /* saa717x video encoder */ #define printable(c) ((((c) & 0x7F) < 0x20 || ((c) & 0x7F) > 0x7E) ? '.' : ((c) & 0x7F)) int valid_char(char c) { /* Invalid Character */ if (((c) & 0x7F) < 0x20 || ((c) & 0x7F) > 0x7E) return 0; else /* Valid Character */ return 1; } int frames = 0; int lines = 0; int space_needed = 0; int text_off = 0; int page = -1; int show_wss = 1; int show_ttx = 1; int show_vps = 1; static const char *formats[] = { "Full format 4:3, 576 lines", "Letterbox 14:9 centre, 504 lines", "Letterbox 14:9 top, 504 lines", "Letterbox 16:9 centre, 430 lines", "Letterbox 16:9 top, 430 lines", "Letterbox > 16:9 centre", "Full format 14:9 centre, 576 lines", "Anamorphic 16:9, 576 lines" }; static const char *subtitles[] = { "none", "in active image area", "out of active image area", "?" }; /* ETS 300 706, Section 8.2 Hamming 8/4 */ /* Hamming code copied from zvbi */ const int8_t _vbi_hamm8_inv [256] = { 0x01, 0xff, 0x01, 0x01, 0xff, 0x00, 0x01, 0xff, 0xff, 0x02, 0x01, 0xff, 0x0a, 0xff, 0xff, 0x07, 0xff, 0x00, 0x01, 0xff, 0x00, 0x00, 0xff, 0x00, 0x06, 0xff, 0xff, 0x0b, 0xff, 0x00, 0x03, 0xff, 0xff, 0x0c, 0x01, 0xff, 0x04, 0xff, 0xff, 0x07, 0x06, 0xff, 0xff, 0x07, 0xff, 0x07, 0x07, 0x07, 0x06, 0xff, 0xff, 0x05, 0xff, 0x00, 0x0d, 0xff, 0x06, 0x06, 0x06, 0xff, 0x06, 0xff, 0xff, 0x07, 0xff, 0x02, 0x01, 0xff, 0x04, 0xff, 0xff, 0x09, 0x02, 0x02, 0xff, 0x02, 0xff, 0x02, 0x03, 0xff, 0x08, 0xff, 0xff, 0x05, 0xff, 0x00, 0x03, 0xff, 0xff, 0x02, 0x03, 0xff, 0x03, 0xff, 0x03, 0x03, 0x04, 0xff, 0xff, 0x05, 0x04, 0x04, 0x04, 0xff, 0xff, 0x02, 0x0f, 0xff, 0x04, 0xff, 0xff, 0x07, 0xff, 0x05, 0x05, 0x05, 0x04, 0xff, 0xff, 0x05, 0x06, 0xff, 0xff, 0x05, 0xff, 0x0e, 0x03, 0xff, 0xff, 0x0c, 0x01, 0xff, 0x0a, 0xff, 0xff, 0x09, 0x0a, 0xff, 0xff, 0x0b, 0x0a, 0x0a, 0x0a, 0xff, 0x08, 0xff, 0xff, 0x0b, 0xff, 0x00, 0x0d, 0xff, 0xff, 0x0b, 0x0b, 0x0b, 0x0a, 0xff, 0xff, 0x0b, 0x0c, 0x0c, 0xff, 0x0c, 0xff, 0x0c, 0x0d, 0xff, 0xff, 0x0c, 0x0f, 0xff, 0x0a, 0xff, 0xff, 0x07, 0xff, 0x0c, 0x0d, 0xff, 0x0d, 0xff, 0x0d, 0x0d, 0x06, 0xff, 0xff, 0x0b, 0xff, 0x0e, 0x0d, 0xff, 0x08, 0xff, 0xff, 0x09, 0xff, 0x09, 0x09, 0x09, 0xff, 0x02, 0x0f, 0xff, 0x0a, 0xff, 0xff, 0x09, 0x08, 0x08, 0x08, 0xff, 0x08, 0xff, 0xff, 0x09, 0x08, 0xff, 0xff, 0x0b, 0xff, 0x0e, 0x03, 0xff, 0xff, 0x0c, 0x0f, 0xff, 0x04, 0xff, 0xff, 0x09, 0x0f, 0xff, 0x0f, 0x0f, 0xff, 0x0e, 0x0f, 0xff, 0x08, 0xff, 0xff, 0x05, 0xff, 0x0e, 0x0d, 0xff, 0xff, 0x0e, 0x0f, 0xff, 0x0e, 0x0e, 0xff, 0x0e }; static int vbi_unham8(unsigned int c) { return _vbi_hamm8_inv[(uint8_t) c]; } void decode_wss(struct v4l2_sliced_vbi_data *s) { unsigned char parity; int wss; wss = s->data[0] | (s->data[1] << 8); parity = wss & 15; parity ^= parity >> 2; parity ^= parity >> 1; if (!(parity & 1)) return; printf("WSS: %s; %s mode; %s color coding;\n" " %s helper; reserved b7=%d; %s\n" " open subtitles: %s; %scopyright %s; copying %s\n", formats[wss & 7], (wss & 0x10) ? "film" : "camera", (wss & 0x20) ? "MA/CP" : "standard", (wss & 0x40) ? "modulated" : "no", !!(wss & 0x80), (wss & 0x0100) ? "have TTX subtitles; " : "", subtitles[(wss >> 9) & 3], (wss & 0x0800) ? "surround sound; " : "", (wss & 0x1000) ? "asserted" : "unknown", (wss & 0x2000) ? "restricted" : "not restricted"); } static int odd_parity(uint8_t c) { c ^= (c >> 4); c ^= (c >> 2); c ^= (c >> 1); return c & 1; } static void decode_xds(struct v4l2_sliced_vbi_data *s) { char c; //printf("XDS: %02x %02x: ", s->data[0], s->data[1]); c = odd_parity(s->data[0]) ? s->data[0] & 0x7F : '?'; c = printable(c); //putchar(c); c = odd_parity(s->data[1]) ? s->data[1] & 0x7F : '?'; c = printable(c); //putchar(c); //putchar('\n'); } #define CC_SIZE 64 static void decode_cc(struct v4l2_sliced_vbi_data *s) { static int xds_transport = 0; char c = s->data[0] & 0x7F; static char cc[CC_SIZE + 1]; static char cc_last[2 + 1] = { 0, 0 }; char cc_disp[CC_SIZE + 1]; static int cc_idx; if (s->field) { /* field 2 */ /* 0x01xx..0x0Exx ASCII_or_NUL[0..32] 0x0Fchks */ if (odd_parity(s->data[0]) && (c >= 0x01 && c <= 0x0F)) { decode_xds(s); xds_transport = (c != 0x0F); } else if (xds_transport) { decode_xds(s); } return; } if (s->data[0] == 0x10 || s->data[0] == 0x13 || s->data[0] == 0x15 || s->data[0] == 0x16 || s->data[0] == 0x91 || s->data[0] == 0x92 || s->data[0] == 0x94 || s->data[0] == 0x97 || s->data[0] == 0x1c) { if (text_off) { if (s->data[0] == 0x94 && (s->data[1] == 0xad || s->data[1] == 0x25)) { text_off = 0; } } else { if (s->data[0] == 0x1c && (s->data[1] == 0x2a || s->data[1] == 0xab)) { text_off = 1; } } } if (text_off == 0) { c = odd_parity(s->data[0]) ? s->data[0] & 0x7F : '?'; if (cc_idx >= CC_SIZE) { cc_idx = CC_SIZE - 2; memcpy(cc, cc + 2, cc_idx); } cc[cc_idx++] = c; c = odd_parity(s->data[1]) ? s->data[1] & 0x7F : '?'; cc[cc_idx++] = c; cc[cc_idx] = 0; } if (cc_idx == CC_SIZE) { int x = 0, y = 0; int debug = 0; memset(cc_disp, 0, CC_SIZE); if (debug) fprintf(stderr, "\n"); for (y = 0, x = 0; y < cc_idx;) { /* Control Code or Valid Character */ if (valid_char(cc[y]) == 0) { if (debug) { if (cc[y] == 0x00) fprintf(stderr, "()"); else fprintf(stderr, "(0x%02x)", cc[y]); } /* skip over control code */ if (cc[y] >= 0x11 && cc[y] <= 0x1f) { if (debug) { if (cc[y + 1] == 0x00) fprintf(stderr, "()"); else fprintf(stderr, "(0x%02x)", cc[y + 1]); } if (space_needed == 1) { space_needed = 0; cc_disp[x++] = ' '; lines++; } else if (cc[y] == 0x14 && cc[y + 1] == 0x14) { space_needed = 0; cc_disp[x++] = ' '; lines++; } cc_last[0] = cc[y]; cc_last[1] = cc[y + 1]; y += 2; } else { cc_last[0] = cc_last[1]; cc_last[1] = cc[y]; y++; } } else { if (debug) fprintf(stderr, "(%c)", cc[y] & 0x7F); /* Record character */ if ((cc[y] & 0x7F) == '\n') { cc_disp[x] = ' '; lines++; } else if (cc_last[1] == 0x2B && cc_last[0] == 0x14 && (cc[y] & 0x7F) == '@') { /* Do Nothing */ cc_last[0] = cc_last[1]; cc_last[1] = cc[y]; y++; continue; } else if ((cc[y] & 0x7F) != '\n') { cc_disp[x] = cc[y] & 0x7F; lines++; } else { printf("\nOdd Character (%c)\n", cc[y] & 0x7F); } space_needed = 1; x++; cc_last[0] = cc_last[1]; cc_last[1] = cc[y]; y++; } /* Insert CC_SIZE char Line Break */ if (lines >= CC_SIZE && cc_disp[x - 1] == ' ') { cc_disp[x++] = '\n'; lines = 0; space_needed = 0; } } if (debug) fprintf(stderr, "\n"); printf("%s", cc_disp); memset(cc_disp, 0, CC_SIZE); //memset(cc, 0, CC_SIZE); cc_idx = 0; } } const uint8_t vbi_bit_reverse[256] = { 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff }; #define printable(c) ((((c) & 0x7F) < 0x20 || ((c) & 0x7F) > 0x7E) ? '.' : ((c) & 0x7F)) #define PIL(day, mon, hour, min) \ (((day) << 15) + ((mon) << 11) + ((hour) << 6) + ((min) << 0)) static void dump_pil(int pil) { int day, mon, hour, min; day = pil >> 15; mon = (pil >> 11) & 0xF; hour = (pil >> 6) & 0x1F; min = pil & 0x3F; if (pil == PIL(0, 15, 31, 63)) printf(" PDC: Timer-control (no PDC)\n"); else if (pil == PIL(0, 15, 30, 63)) printf(" PDC: Recording inhibit/terminate\n"); else if (pil == PIL(0, 15, 29, 63)) printf(" PDC: Interruption\n"); else if (pil == PIL(0, 15, 28, 63)) printf(" PDC: Continue\n"); else if (pil == PIL(31, 15, 31, 63)) printf(" PDC: No time\n"); else printf(" PDC: %05x, 200X-%02d-%02d %02d:%02d\n", pil, mon, day, hour, min); } void decode_vps(struct v4l2_sliced_vbi_data *s) { static char pr_label[20]; static char label[20]; static int l = 0; int cni, pcs, pty, pil; int c; unsigned char *buf = s->data; c = vbi_bit_reverse[buf[1]]; if ((int8_t) c < 0) { label[l] = 0; memcpy(pr_label, label, sizeof(pr_label)); l = 0; } c &= 0x7F; label[l] = printable(c); l = (l + 1) % 16; printf("VPS: 3-10: %02x %02x %02x %02x %02x %02x %02x %02x (\"%s\")\n", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], pr_label); pcs = buf[2] >> 6; cni = ((buf[2] & 0xf) << 12) + ((buf[10] & 3) << 10) + ((buf[11] & 0xC0) << 2) + ((buf[8] & 0xC0) << 0) + (buf[11] & 0x3F); pil = ((buf[8] & 0x3F) << 14) + (buf[9] << 6) + (buf[10] >> 2); pty = buf[12]; printf(" CNI: %04x PCS: %d PTY: %d ", cni, pcs, pty); dump_pil(pil); } static void teletext(struct v4l2_sliced_vbi_data *s) { unsigned char mag = (vbi_unham8(s->data[1]) << 4) | vbi_unham8(s->data[0]); static int last_page[8]; static int last_page1; static int sub = 0; static int inh = 0; static int ser = 0; int i = 2; if ((mag >> 3) == 0) { unsigned char mg = mag & 7; unsigned short pg = (vbi_unham8(s->data[3]) << 4) | vbi_unham8(s->data[2]); if (mg == 0) mg = 8; pg += mg * 256; last_page1 = last_page[mag & 7] = pg; if (page != -1 && pg != page) { return; } i = 10; } else if (page != -1 && (ser ? last_page1 : last_page[mag & 7]) != page) return; if ((mag >> 3) == 0) { unsigned char c = vbi_unham8(s->data[9]); ser = c * 1; c = vbi_unham8(s->data[7]); sub = c & 8; c = vbi_unham8(s->data[8]); inh = c & 8; if (c & 1) return; } if (inh) return; if ((mag >> 3) > 24) return; while (i < 42) { int c = s->data[i] & 0x7f; printf("%c", c >= 32 ? c : ' '); i++; } printf("\n"); } void process(struct v4l2_sliced_vbi_data *s) { if (s->id == 0) return; //printf("%04d: line %02u field %d type %x\n", frames, s->line, s->field, s->id); switch (s->id) { case V4L2_SLICED_TELETEXT_B: if (show_ttx) teletext(s); break; case V4L2_SLICED_VPS: if (s->line != 16 || s->field) break; if (show_vps) decode_vps(s); break; case V4L2_SLICED_WSS_625: if (s->line != 23 || s->field) break; if (show_wss) decode_wss(s); break; case V4L2_SLICED_CAPTION_525: if (s->line != 21) break; decode_cc(s); break; default: printf("unknown\n"); break; } } static void sigalrm(int s) { exit(0); } static void cc_readback(int fh) { struct v4l2_sliced_vbi_data data; struct v4l2_dbg_register v; int parity[2]; int cc_cnt = 0; int field = -1; v.match.type = V4L2_CHIP_MATCH_I2C_DRIVER; v.match.addr = I2C_DRIVERID_CX25840; v.reg = 0x444; if (ioctl(fh, VIDIOC_DBG_G_REGISTER, &v)) { v.match.addr = I2C_DRIVERID_SAA711X; printf("saa711x\n"); } else printf("cx25840\n"); while (1) { if (v.match.addr == I2C_DRIVERID_CX25840) { v.reg = 0x444; ioctl(fh, VIDIOC_DBG_G_REGISTER, &v); if ((v.val & 32) == 32) { int skip = v.val; v.reg = 0x445; ioctl(fh, VIDIOC_DBG_G_REGISTER, &v); if (skip & 16) continue; parity[cc_cnt] = v.val & 128; data.data[cc_cnt++] = v.val; if (cc_cnt == 2) { data.field = 0; if (odd_parity(data.data[0] && odd_parity(data.data[1]))) decode_cc(&data); cc_cnt = 0; } continue; } } else { v.reg = 0x66; ioctl(fh, VIDIOC_DBG_G_REGISTER, &v); if ((v.val & 0x30) == 0 && (v.val & 0xe) != field) { v.reg = 0x69; ioctl(fh, VIDIOC_DBG_G_REGISTER, &v); data.data[0] = v.val; v.reg = 0x6a; ioctl(fh, VIDIOC_DBG_G_REGISTER, &v); data.data[1] = v.val; data.field = 0; if (odd_parity(data.data[0] && odd_parity(data.data[1]))) decode_cc(&data); continue; } } struct timeval tv = { 0, 100 }; select(0, NULL, NULL, NULL, &tv); } } int main(int argc, char **argv) { char device[100] = "/dev/vbi0"; struct v4l2_format fmt; v4l2_std_id std; struct v4l2_sliced_vbi_data *buf; int timeout = 0; int readback = 0; int fh; while (1) { int ch = getopt(argc, argv, "d:t:hp:rs:"); if (ch == -1) break; switch (ch) { case 'd': strcpy(device, optarg); if (optarg[0] >= '0' && optarg[0] <= '9') sprintf(device, "/dev/vbi%s", optarg); break; case 't': timeout = atol(optarg); break; case 'p': page = atol(optarg); page = ((page / 100) << 8) | (((page / 10) % 10) << 4) | (page % 10); break; case 'r': readback = 1; break; case 's': show_ttx = strstr(optarg, "teletext") != NULL; show_vps = strstr(optarg, "vps") != NULL; show_wss = strstr(optarg, "wss") != NULL; break; default: fprintf(stderr, "usage: %s [-d ] [-t ] [-p ] [-s teletext,wss,vps] [-r] [-h]\n" "defaults are /dev/vbi0 and no timeout\n" "-p selects teletext page\n" "-r switches to using the readback registers on the digitizer\n" "-s selects what to show\n", argv[0]); exit(-1); } } fh = open(device, O_RDONLY); if (fh == -1) { fprintf(stderr, "cannot open %s\n", device); return 1; } setbuf(stdout, NULL); ioctl(fh, VIDIOC_G_STD, &std); fmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE; fmt.fmt.sliced.service_set = (std & V4L2_STD_NTSC) ? V4L2_SLICED_VBI_525 : V4L2_SLICED_VBI_625; fmt.fmt.sliced.reserved[0] = 0; fmt.fmt.sliced.reserved[1] = 0; if (ioctl(fh, VIDIOC_S_FMT, &fmt) < 0) { perror("vbi"); close(fh); return 1; } fprintf(stderr, "%08x, %d\n", fmt.fmt.sliced.service_set, fmt.fmt.sliced.io_size); if (timeout) { signal(SIGALRM, sigalrm); alarm(timeout); } if (readback) { cc_readback(fh); close(fh); return 0; } buf = malloc(fmt.fmt.sliced.io_size); for (;;) { int size = read(fh, buf, fmt.fmt.sliced.io_size); int i; if (size <= 0) break; frames++; for (i = 0; i < size / sizeof(struct v4l2_sliced_vbi_data); i++) { process(&buf[i]); } } close(fh); return 0; } ivtv-utils-1.4.1/doc/0000775000076400007640000000000011355717714013105 5ustar andyandyivtv-utils-1.4.1/doc/conversion.txt0000664000076400007640000002106511355717530016033 0ustar andyandyThis documents how to convert the ivtv-proprietry ioctls to the new V4L2 ioctls. ---------------------------------------- ioctl IVTVFB_IOCTL_SET_WINDOW: use VIDIOC_S_CROP instead with type set to V4L2_BUF_TYPE_VIDEO_OUTPUT. The v4l2_rect c contains the top/left position and the size to which the video is scaled. ---------------------------------------- ioctl IVTV_IOC_S/G_YUV_INTERLACE: Use VIDIOC_S/G_FMT with type V4L2_BUF_TYPE_VIDEO_OUTPUT. The 'field' member of v4l2_pix_format contains the current or can be set to the field order. IVTV_YUV_MODE_INTERLACED | IVTV_YUV_SYNC_EVEN maps to V4L2_FIELD_INTERLACED_TB. IVTV_YUV_MODE_INTERLACED | IVTV_YUV_SYNC_ODD maps to V4L2_FIELD_INTERLACED_BT. IVTV_YUV_MODE_PROGRESSIVE maps to V4L2_FIELD_NONE. IVTV_YUV_MODE_AUTO maps to V4L2_FIELD_ANY (the default). It is no longer possible to set the threshold for the 'auto' mode. That is done by the driver. --------------------------------------- The chromakey and local/global alpha settings of the framebuffer are now set using the v4l2 overlay functionality. A new buffer type V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY was added to support output overlays. By specifying this type with VIDIOC_S_FMT and filling in the chromakey and/or global_alpha values of the v4l2_window struct you can change the chromakey and global alpha. To enable/disable chromakey/global alpha/local alpha in the framebuffer you call VIDIOC_S_FBUF and specify the new flags V4L2_FBUF_FLAG_LOCAL_ALPHA and V4L2_FBUF_FLAG_GLOBAL_ALPHA. The corresponding capabilities V4L2_FBUF_CAP_LOCAL_ALPHA and V4L2_FBUF_CAP_GLOBAL_ALPHA are also added. All this replaces the following old ioctls: IVTVFB_IOCTL_GET_COLORKEY IVTVFB_IOCTL_SET_COLORKEY IVTVFB_IOCTL_GET_ALPHA IVTVFB_IOCTL_SET_ALPHA IVTVFB_IOCTL_GET_STATE IVTVFB_IOCTL_SET_STATE --------------------------------------- ioctl IVTV_IOC_PREP_FRAME_YUV has been replaced with IVTV_IOC_DMA_FRAME. This is still an ioctl specific to ivtv. It might or might not be replaced by something better in the future. The media/ivtv.h header contains clear instructions on the use of this ioctl. Make sure you fill in the new 'type' field! --------------------------------------- ivtv now uses the linux/dvb/audio.h and linux/dvb/video.h ioctls for commanding the MPEG decoder (PVR-350). In order to support everything ivtv needs those ioctls have been extended as well. So you will have to include these headers to be able to command the MPEG decoder. -------------------------------------- ioctls IVTV_IOC_S_VBI_PASSTHROUGH and IVTV_IOC_G_VBI_PASSTHROUGH are removed. By default the driver attempts to passthrough VBI data whenever possible in passthrough mode. ------------------------------------- ioctl IVTV_IOC_DEC_FLUSH is removed. Flushing buffers is handled internally by the driver. ------------------------------------- ioctl IVTV_IOC_PASSTHROUGH is replaced by ioctl VIDEO_SELECT_SOURCE: use VIDEO_SOURCE_MEMORY to turn the passthrough mode off, use VIDEO_SOURCE_DEMUX to turn it on. ------------------------------------- The following ioctls: IVTV_IOC_START_DECODE IVTV_IOC_STOP_DECODE IVTV_IOC_G_SPEED IVTV_IOC_S_SPEED IVTV_IOC_DEC_STEP IVTV_IOC_PAUSE_BLACK IVTV_IOC_STOP IVTV_IOC_PLAY IVTV_IOC_PAUSE IVTV_IOC_S_SLOW_FAST IVTV_IOC_DEC_FAST_STOP are replaced by the following ioctls: VIDEO_STOP: stop decoding immediately and set the output to black. VIDEO_PLAY: start decoding at normal speed. VIDEO_FREEZE: pause decoding, keep the last frame. VIDEO_CONTINUE: continue decoding. VIDEO_COMMAND VIDEO_TRY_COMMAND: these two ioctls work similar to the VIDIOC_[TRY_]ENCODER_COMMAND ioctls. The following commands exist: VIDEO_CMD_PLAY: the play.speed value of the video_command struct selects the speed as follows: 0 or 1000 specifies normal speed, 1 specifies forward single stepping, -1 specifies backward single stepping, >1: playback at speed/1000 of the normal speed, <-1: reverse playback at (-speed/1000) of the normal speed. On return the play.format value tells you how to feed data to the decoder: /* The decoder has no special format requirements */ #define VIDEO_PLAY_FMT_NONE (0) /* The decoder requires full GOPs */ #define VIDEO_PLAY_FMT_GOP (1) NOTE: if you change playback direction then at this moment you have to stop the decoder first, then start again with the new speed setting. More research is needed to determine if this can be avoided. VIDEO_CMD_STOP: stop decoding. Two flags are available: #define VIDEO_CMD_STOP_TO_BLACK (1 << 0) #define VIDEO_CMD_STOP_IMMEDIATELY (1 << 1) By default the decoder keeps the last frame and waits until all pending buffers are decoded. 'STOP_IMMEDIATELY' will flush all queues and stop at once. You can also stop at the specified stop.pts value. VIDEO_CMD_FREEZE: pause the decoder. One flag is available with this command: #define VIDEO_CMD_FREEZE_TO_BLACK (1 << 0) By default the decoder keeps the last frame. VIDEO_CMD_CONTINUE: continue decoding. ------------------------------------- ioctls IVTV_IOC_G_PTS and IVTV_IOC_GET_TIMING are replaced by: VIDEO_GET_FRAME_COUNT VIDEO_GET_PTS It is no longer possible to obtain the SCR timestamp. ------------------------------------- ioctl IVTV_IOC_S_AUDMODE has been replaced with ioctls AUDIO_CHANNEL_SELECT and AUDIO_BILINGUAL_CHANNEL_SELECT. Possible channel selections are: AUDIO_STEREO, AUDIO_MONO_LEFT, AUDIO_MONO_RIGHT, AUDIO_MONO, AUDIO_STEREO_SWAPPED AUDIO_CHANNEL_SELECT selects the audio output for a normal, one-language stream, AUDIO_BILINGUAL_CHANNEL_SELECT selects the audio output for a bilingual stream. The decoder automatically detects whether it is a bilingual stream or not and uses the corresponding setting. ------------------------------------- AUDIO_SET_MUTE is now used to select whether the audio is muted during 1.5 or 0.5 speed playback. By default the audio is not muted. During normal playback audio is never muted and this ioctl has no effect on that. ------------------------------------- ioctl IVTV_IOC_FRAMESYNC is replaced by VIDEO_GET_EVENT. ivtv support two events: VIDEO_EVENT_DECODER_STOPPED and VIDEO_EVENT_VSYNC. The first arrives when the decoder finishes decoding, the second arrives at every Vsync (and so is very frequent). If an event has arrived, then a select/poll that also waits for exceptions will return and the exception bit is set. You have to call VIDEO_GET_EVENT to discover which event arrived. If you call VIDEO_GET_EVENT and there was no pending event, then this ioctl will block until an event arrives (unless the file handle was set to non blocking, in that case the ioctl will return immediately). If the type was VIDEO_EVENT_VSYNC, then vsync_field will contain the field identifier. So IVTV_IOC_FRAMESYNC can be replaced by a call to VIDEO_GET_EVENT, possibly followed by calls to VIDEO_GET_PTS and/or VIDEO_GET_FRAME_COUNT to get the corresponding PTS/frame count. Note that Vsync events are only recorded if 1) the application has called poll/select or 2) if the application called VIDEO_GET_EVENT. So if you are never interested in this event, then there is also no overhead. Here is a copy of the relevant defines/struct from linux/dvb/video.h: /* FIELD_UNKNOWN can be used if the hardware does not know whether the Vsync is for an odd, even or progressive (i.e. non-interlaced) field. */ #define VIDEO_VSYNC_FIELD_UNKNOWN (0) #define VIDEO_VSYNC_FIELD_ODD (1) #define VIDEO_VSYNC_FIELD_EVEN (2) #define VIDEO_VSYNC_FIELD_PROGRESSIVE (3) struct video_event { int32_t type; #define VIDEO_EVENT_SIZE_CHANGED 1 #define VIDEO_EVENT_FRAME_RATE_CHANGED 2 #define VIDEO_EVENT_DECODER_STOPPED 3 #define VIDEO_EVENT_VSYNC 4 time_t timestamp; union { video_size_t size; unsigned int frame_rate; /* in frames per 1000sec */ unsigned char vsync_field; /* unknown/odd/even/progressive */ } u; }; ------------------------------- ioctl IVTV_IOC_GET_FB: this ioctl no longer exists, but the best way to find the framebuffer that corresponds to the v4l2 video device is using the following code: fd is the video output file descriptor: struct v4l2_framebuffer fbuf; int fbi; ioctl(fd, VIDIOC_G_FBUF, &fbuf); for (fbi = 0; fbi < 10; fbi++) { struct fb_fix_screeninfo si; char buf[10]; sprintf(buf, "/dev/fb%d", fbi); ffb = open(buf, O_RDWR); if (ffb < 0) continue; ioctl(ffb, FBIOGET_FSCREENINFO, &si); if (si.smem_start == (unsigned long)fbuf.base) break; close(ffb); ffb = -1; } if (ffb == -1) { fprintf(stderr, "Cannot find framebuffer\n"); exit(1); } So the smem_start from struct fb_fix_screeninfo should match the base from struct v4l2_framebuffer. Both are pointers to the start of the same framebuffer. ivtv-utils-1.4.1/doc/README.utils0000664000076400007640000000157311355717530015126 0ustar andyandyREADME for the IVTV Utilities Introduction ============ This document describes the utilities supporting the ivtv modules. v4l2-ctl -------- This is a copy of the same utility that is available from the linux v4l-dvb repository (www.linuxtv.org). It can be used to set, list and get almost everything that the v4l2 API offers. ivtvctl ------- Similar to v4l2-ctl, but only contains ivtv-specific features. Eventually all ivtv functionality should be moved into v4l2-ctl, and then this utility will be removed. ivtvfbctl --------- This utility lets you set the alpha/transparency of the OSD. It also has other functions (FIXME) radio ----- A simple - but functioning - radio application See README.radio for more details ivtv-tune --------- Contains many frequency tables which allow you to tune to particular channels. Functional replacement for ptune.pl ivtvplay mpegindex encoder ivtv-utils-1.4.1/doc/README.devices0000664000076400007640000001135511355717530015407 0ustar andyandyREADME for the IVTV Devices Introduction ============ The ivtv modules are accessed through their device entries. This document describes these devices. Devices ======= There may be multiple devices depending on how many cards your system has installed. A maximum of 12 cards are allowed at the moment. Cards that don't have a video output capability (i.e. non PVR350 cards) lack the vbi8, vbi16, video16 and video48 devices. They also do not support the framebuffer device /dev/fbx for OSD. The radio0 device may or may not be present, depending on whether the card has a radio tuner or not. The eeprom output will tell you this. Here is a list of the base v4l devices: crw-rw---- 1 root video 81, 0 Jun 19 22:22 /dev/video0 crw-rw---- 1 root video 81, 16 Jun 19 22:22 /dev/video16 crw-rw---- 1 root video 81, 24 Jun 19 22:22 /dev/video24 crw-rw---- 1 root video 81, 32 Jun 19 22:22 /dev/video32 crw-rw---- 1 root video 81, 48 Jun 19 22:22 /dev/video48 crw-rw---- 1 root video 81, 64 Jun 19 22:22 /dev/radio0 crw-rw---- 1 root video 81, 224 Jun 19 22:22 /dev/vbi0 crw-rw---- 1 root video 81, 228 Jun 19 22:22 /dev/vbi8 crw-rw---- 1 root video 81, 232 Jun 19 22:22 /dev/vbi16 Base devices ============ For every extra card you have the numbers increased by one. For example, /dev/video0 is listed as the 'base' encoding capture device so we have: /dev/video0 is the encoding capture device for the first card (card 0) /dev/video1 is the encoding capture device for the second card (card 1) /dev/video2 is the encoding capture device for the third card (card 2) Note that if the first card doesn't have a feature (eg no decoder, so no video16, the second card will still use video17. The simple rule is 'add the card number to the base device number'. If you have other capture cards (e.g. WinTV PCI) that are detected first, then you have to tell the ivtv module about it so that it will start counting at 1 (or 2, or whatever). Otherwise the device numbers can get confused. See the ivtv_first_minor module option for more information. /dev/video0 The encoding capture device(s). Read-only. Reading from this device results in an encoded mpeg2 capture from the selected ivtv inputs. This device multiplexes the selected audio and video inputs into the mpeg2 stream. Example: cat /dev/video0 > my.mpg (you need to hit ctrl-c to exit) /dev/video16 The decoder output device(s) Write-only. Only present if the MPEG decoder (i.e. CX23415) exists. An mpeg2 stream sent to this device will appear on the selected video display, audio will appear on the line-out/audio out. It is only available for cards that support video out. Example: cat my.mpg >/dev/video16 /dev/video24 The raw audio capture device(s). Read-only The raw audio PCM stereo stream from the currently selected tuner or audio line-in. Reading from this device results in a raw (signed 16 bit Little Endian, 48000 Hz, stereo pcm) capture from the selected ivtv inputs. This device only captures audio. /dev/video32 The raw video capture device(s) Read-only The raw YUV video output from the current video input. The YUV format is non-standard (HME12?) but with the yuv-fixup=1 ivtv module option it is converted to standard YUV format. /dev/video48 The raw video display device(s) Write-only. Only present if the MPEG decoder (i.e. CX23415) exists. Writes a YUV stream to the decoder of the card. Does not currently work. This is on the TODO list but at a low priority. /dev/radio0 The radio tuner device(s) Cannot be read or written. Used to enable the radio tuner and tune to a frequency. You cannot read or write audio streams with this device. Once you use this device to tune the radio, use /dev/video24 to read the raw pcm stream or /dev/video0 to get an mpeg2 stream with black video. /dev/vbi0 The 'vertical blank interval' (Teletext, CC, WSS etc) capture device(s) Read-only Captures the raw video data sent during the Vertical Blank Interval. This data is used to encode teletext, closed captions, VPS, widescreen signalling, electronic program guide information, and other services. See also README.vbi /dev/vbi8 Processed vbi feedback device(s) Read-only. Only present if the MPEG decoder (i.e. CX23415) exists. The sliced VBI data embedded in an MPEG stream is reproduced on this device. So while playing back a recording on /dev/video16, you can read the embedded VBI data from /dev/vbi8 /dev/vbi16 The vbi 'display' device(s) Write-only. Only present if the MPEG decoder (i.e. CX23415) exists. Can be used to send VBI data to the video-out connector. See also README.vbi /dev/fb[x] Only present if the MPEG decoder (i.e. CX23415) exists. This device is a linux framebuffer for the ivtv OSD display. ivtv-utils-1.4.1/doc/video-quality.txt0000664000076400007640000000412011355717530016433 0ustar andyandyThis document discusses a few aspects of video quality Output ====== The PVR350 can output via composite or s-video (RGB?? FIX) The s-video signal is far superior from a video quality perspective. If your tv doesn't have an s-video socket but does have an s-video mode, you may be able to use an s-video to SCART convertor. (careful, some cheap s-video/scart convertors don't work properly - if you get a black and white picture try another) Video Artefacts =============== 1. Faint diagonal lines seen on s-video signals sent through the scart plug. These can be caused when the card outputs s-video and composite at the same time. The solution is to use: ivtvctl -l 2 which sets s-video only 2. diagonal coloured lines appearing on recordings. There is speculation that the Macrovision filter is being triggered. Reloading the modules should fix this. (FIX - still relevant?) 3. black screen with diagonal white lines Happens when the driver thinks you are using PAL, while the tuner or s-video in signal is NTSC or vice versa. Check which tuner is autodetected or specified to see if there is no mistake there. MPEG Settings ============= If you are experiencing visual artifacts (ghosting of people, etc.) you probably want to play around with the dnr settings. You can use ivtvctl or record-v4l2.pl to set them. dnr_mode: 0: spatial and temporal noise removal filters 1: temporal only 2: spatial only 3: no noise filter dnr_spatial: 0..16: 0=no filtering 16=strongest filter (horizontal only, smoothing/lowpass) dnr_temporal: 0..16: 0=no filtering 16=strongest filter (inter-frame (time dimension), averaging) if you know mplayer's denoise3d or hqdn3d filter, then dnr_spatial is the same as its first parameter, and dnr_temporal is the same as its 3rd param. if you set dnr_temporal too high (say 16) you'll get motion blur effect. if you set dnr_spatial too high, you get image horizontaly blured. dnr_type: dunno, i couldn't find the effect of this parameter. it doesn't change anything visible for me. any ideas? ivtv-utils-1.4.1/doc/README.vbi0000664000076400007640000002553511355717530014552 0ustar andyandyREADME for the IVTV VBI Support Hans Verkuil (hverkuil@xs4all.nl) [NOTE: parts of this document are outdated. Sliced VBI is now setup using a standard V4L2 API. See test/vbi.c or test/vbi-detect.c for an example of the new API. The format of the sliced VBI data embedded in the MPEG stream is still valid though.] Introduction ============ This document provides information on the ivtv VBI support and the vbi utility. Many thanks must go to Chris Kennedy for helping out on the NTSC support for VBI. The TV signal uses the Vertical Blank Interval (i.e. the time between finishing one picture and moving the electron beam up to start another) for special data services like teletext, closed caption and the widescreen signal. The saa7115 chip supports these standards. It can provide the data in either raw format (720 luminosity samples per line) or in a sliced format (here the chip decodes the luminosity samples to the actual bytes). It also has read-back registers where the data of several small-payload VBI standards is stored. There are some cards that use the saa7114 chip. While this chip does support VBI, it is currently not working, so for these cards VBI is disabled. Patches ======= Not all programs use the v4l2 API properly, so a few patches are provided: - zvbi.diff fixes the libzvbi library (http://sourceforge.net/projects/zapping, versions 2.7.0 & 2.8.0). The patch is needed because the library expects streaming ioctls which are not (yet) available at the moment. - alevt.diff fixes incorrect v4l2 defines (probably derived from older v4l2 API revisions). The patch is for version 1.6.1 and this teletext decoder/browser can be found here: http://www.goron.de/~froese (although this site seems to be down a lot). Those who are using nxtvepg (Electronic Program Guide, http://nxtvepg.sourceforge.net) must upgrade to version 2.7.1 and higher. Older versions had some bugs in the use of the V4L2 API. Raw VBI output ============== Current linux VBI decoding applications only accept raw VBI data. While a proposal for a sliced VBI v4l2 API is available, it is not yet implemented. The ivtv driver adds its own API for sliced VBI data which is modelled on the proposal. For the testing of raw VBI output I have used the libzvbi library with the patch mentioned in the previous section applied. The VBI output appears at device /dev/vbi0. By running 'osc -d /dev/vbi0' from the zvbi test directory you should see the raw VBI lines. Use the up/down arrow keys to see all VBI lines. Use the capture tool to actually extract the data. See the README file in the zvbi test directory for more information. VBI mode ioctls =============== Even though /dev/vbi0 can be set to sliced VBI mode, as soon as the VIDIOC_G_FMT or VIDIOC_S_FMT ioctls are used it is switched to raw VBI mode. All currently available linux utilities use these ioctls and expect to see raw VBI mode. The vbi.c example utility shows how to use the sliced VBI mode. It is my hope that this utility will be expanded to support all the main VBI standards and can be used as a reference for other programs. Currently only the PAL WSS signal and PAL VPS signal are fully decoded. Closed captioning for NTSC is partially decoded. Two new ioctls are added: IVTV_IOC_S_VBI_MODE and IVTV_IOC_G_VBI_MODE. These should be used to set and get the VBI mode. You must provide a pointer to the following structure: struct ivtv_sliced_vbi_format { unsigned long service_set; /* one or more of the IVTV_SLICED_ defines */ unsigned long packet_size; /* the size in bytes of the ivtv_sliced_data packet */ unsigned long io_size; /* maximum number of bytes passed by one read() call */ unsigned long reserved; }; The IVTV_IOC_G_VBI_MODE ioctl will fill in this structure with the current settings. The packet_size and io_size fields are discussed in the Sliced VBI Output Format section below. For the IVTV_IOC_S_VBI_MODE ioctl you only have to fill in the service_set. The service_set member has the following values: #define IVTV_SLICED_TELETEXT_B (1 << 0) #define IVTV_SLICED_CAPTION_625 (1 << 1) #define IVTV_SLICED_CAPTION_525 (1 << 2) #define IVTV_SLICED_WSS_625 (1 << 3) #define IVTV_SLICED_VPS (1 << 4) If service_set is set to 0, then the VBI format is reset to raw VBI. The IVTV_IOC_S_VBI_MODE will update the values of the other ivtv_sliced_vbi_format fields on return. Sliced VBI output format ======================== You must call the IVTV_IOC_G_VBI_MODE ioctl to obtain the packet_size and io_size values. These values are based on the proposed v4l2 sliced VBI API. The packet_size is the size in bytes of the ivtv_sliced_data structure, which contains the sliced data of one VBI line. The io_size is the maximum size in bytes that is passed in one read() call (this is the number of VBI lines in a single frame * packet_size). So you should allocate a buffer of this size. The ivtv_sliced_data structure has the following format: /* This structure is the same as the proposed v4l2_sliced_data structure */ /* id is one of the VBI_SLICED_ flags. */ struct ivtv_sliced_data { unsigned long id; unsigned long line; unsigned char data[]; }; The ID field determines the VBI format of the line. It is one of the VBI_SLICED types or 0 if there is no VBI data in this line. The line field is the line number and data is the actual VBI data. The length of the data array is determined by packet_size - sizeof(struct ivtv_sliced_data). After the payload of the VBI line the data array is padded with 0xA0 bytes. If no data was found in the VBI line that corresponded to the chosen VBI format, then the whole data array is filled with 0xA0 bytes. General Remarks =============== You should set the VBI mode before starting capturing. Once a capture is in progress the VBI_MODE ioctls will return EBUSY. A /dev/vbi8 device is also created. If VBI data is captured in the MPEG stream and is played back on the PVR-350 you can read back the captured VBI stream using this device. Since the VBI data in the MPEG stream is always in sliced format, you should use the same procedure as described in the 'Sliced VBI output format' section. Originally I used DMA for the VBI transfer. It turned out that that interfered with the MPEG DMA, and also that sometimes the VBI DMA transfer did not actually transfer the data. So instead the VBI data is transferred by just copying the memory. Passing captured VBI data to TV-out =================================== When you capture VBI data in the MPEG stream, then the driver is able to pass certain signals on to TV-out. This only works for the Widescreen signal, Close Caption data and VPS data. You use the -b option of ivtvctl to instruct the driver which signals should be captured, and -x that the VBI data should be embedded in the MPEG stream. E.g. use ivtvctl -b wss,cc -x 1 to add WSS and close caption data to the stream (currently works only for the Program Stream). Use the -w option to select which signals are passed on to the TV-out (if supported by your card): ivtvctl -w wss,cc This will automatically copy the wss and cc signals to TV-out. Note that at the moment the CC output is not in sync with the video output. This is still under investigation. Format of embedded VBI data =========================== This section documents the format of the VBI data embedded in an MPEG stream. The stream ID of the VBI data is 0xBD. The maximum size of the embedded data is 4 + 43 * 36, which is 4 bytes for a header and 2 * 18 VBI lines with a 1 byte header and a 42 bytes payload each. Anything beyond this limit is cut off by the firmware. Besides the data for the VBI lines we also need 36 bits for a bitmask determining which lines are captured and 4 bytes for a magic cookie, signifying that this data package contains ivtv VBI data. If all lines are used, then there is no longer room for the bitmask. To solve this two different magic numbers were introduced: 'itv0': After this magic number two unsigned longs follow. Bits 0-17 of the first unsigned long denote which lines of the first field are captured. Bits 18-31 of the first unsigned long and bits 0-3 of the second unsigned long are used for the second field. 'ITV0': This magic number assumes all VBI lines are capture, i.e. it implicitly implies that the bitmasks are 0xffffffff and 0xf. After these magic cookies (and the 8 byte bitmask in case of cookie 'itv0') the captured VBI lines start: For each line the least significant 4 bits of the first byte contain the data type. Possible values are shown in the table below. The payload is in the following 42 bytes. See the function passthrough_vbi_data() in ivtv-vbi.c how to decode the embedded VBI data. Here is the list of possible data types: #define VBI_TYPE_TELETEXT 0x1 // Teletext (uses lines 6-22 for PAL, 10-21 for NTSC) #define VBI_TYPE_CC 0x4 // Closed Captions (line 21 NTSC, line 22 PAL) #define VBI_TYPE_WSS 0x5 // Wide Screen Signal (line 20 NTSC, line 23 PAL) #define VBI_TYPE_VPS 0x7 // Video Programming System (PAL) (line 16) Note that currently only Program Streams are supported! Writing VBI data to TV-out ========================== Just as embedded VBI data can be passed to TV-out, so it is also possible to write VBI data to TV-out using a device: /dev/vbi16. You must first select the signals that should be serviced using the IVTV_IOC_S_VBI_MODE ioctl. Only sliced VBI data is accepted, and only VPS, WSS and CC data can be serviced. Next call the IVTV_IOC_G_VBI_MODE ioctl to obtain the packet size and io_size. Now you can start writing struct ivtv_sliced_data packets to the device. There is currently no way to synchronize with the video. Someone who can actually test closed captioning should implement this. Two example utilities are added to illustrate how to use it. The wss utility can be used to set/unset the WSS signal: 'wss 0 /dev/vbi16' select 4x3 format, 'wss 1 /dev/vbi16' selects 16x9 format. The vbi_passthrough utility can be used to pass the input from /dev/vbi0 directly on to /dev/vbi16. You can test this by turning on passthrough mode (ivtvctl -K 1) and then running vbi_passthrough /dev/vbi0 /dev/vbi16. All WSS, CC and VPS data should be copied to TV-out. TODO ==== 1) Add support for handling teletext-supplied subtitling. It would be nice if only the teletext lines that actually are used for subtitling are inserted into the MPEG stream, to reduce overhead. 2) Add example code that reads the teletext data and shows it using the OSD. Especially useful for subtitling. 3) Extend vbi.c with more VBI format decoders. 4) NTSC and PAL use different ways of programming the saa7115 VBI registers. PAL should use the NTSC method as that is actually a more logical way of doing it. 5) Support the VBI data insertion for more stream types than just Program Stream. ivtv-utils-1.4.1/doc/fw-readme.txt0000664000076400007640000000017011355717530015507 0ustar andyandyThe former firmware documentation has been moved to the v4l-dvb repository, in linux/Documentation/video4linux/cx2341x. ivtv-utils-1.4.1/doc/README.install0000664000076400007640000000732611355717530015436 0ustar andyandyThese instructions are for installing the ivtv driver as a module. IMPORTANT: In case of problems first read this page: http://www.ivtvdriver.org/index.php/Troubleshooting Firmware ======== Instructions on how to obtain and install the required firmware files can be found here: http://www.ivtvdriver.org/index.php/Firmware Kernel 2.6 ========== CONFIG needed: 1. unpack the tarball 2. cd ivtv 3. make 4. make install (as root) 5. unload any old drivers 6. depmod 7. modprobe ivtv Comments: * The driver is not affected by the 4k/8k stacks kernel configuration. Creating device entries ======================= If you are using udev or devfs then devices should be created automatically. Otherwise you may need to: for i in 0 1 2 3 16 32 224 ; do \ if [ ! -f /dev/video$i ]; then \ echo "Creating /dev/video$i" && mknod /dev/video$i c 81 $i && \ chown video /dev/video$i && chmod 660 /dev/video$i; \ else echo "/dev/video$i already exists"; \ fi; \ done ln -s video0 /dev/video Here is a list of the base v4l devices: crw-rw---- 1 root video 81, 0 Jun 19 22:22 /dev/video0 crw-rw---- 1 root video 81, 16 Jun 19 22:22 /dev/video16 crw-rw---- 1 root video 81, 24 Jun 19 22:22 /dev/video24 crw-rw---- 1 root video 81, 32 Jun 19 22:22 /dev/video32 crw-rw---- 1 root video 81, 48 Jun 19 22:22 /dev/video48 crw-rw---- 1 root video 81, 64 Jun 19 22:22 /dev/radio0 crw-rw---- 1 root video 81, 224 Jun 19 22:22 /dev/vbi0 crw-rw---- 1 root video 81, 232 Jun 19 22:22 /dev/vbi8 crw-rw---- 1 root video 81, 248 Jun 19 22:22 /dev/vbi16 Note the permissions of the device entries; your system may differ, so ensure users have appropriate read/write access if receiving "permission denied" errors. Testing the installation ======================== install the modules modprobe ivtv Capture some video cat /dev/video0 > my.mpg (press ctrl-c after a few seconds) play it back (for cards with a decoder only) cat my.mpg >/dev/video16 or mplayer my.mpg or xine my.mpg With any luck you'll see a picture (or more likely static) and hear some sound. You can now use v4l2-ctl to set the input (s-video, audio etc) and ivtv-tune to select a channel. You may also now install the ivtvfb module: (for cards with a decoder only) modprobe ivtvfb This can result in a black screen as nothing is being shown. v4l2-ctl allows you to change the alpha (transparency) settings: v4l2-ctl -d /dev/video16 --set-fmt-output-overlay global_alpha=0 would turn off the fb display (clearest possible video) v4l2-ctl -d /dev/video16 --set-fmt-output-overlay global_alpha=50 would set the framebuffer to be transparency level 50 over the video. Debugging the framebuffer ========================= First make sure everything is wired up correctly. Check video out --------------- remove the video generating module and start it with a testcard image: rmmod ivtv saa7127 modprobe saa7127 test_image=1 modprobe ivtv You should see 8 coloured bars on the screen. Then restore normal operation: rmmod ivtv saa7127 modprobe saa7127 modprobe ivtv Troubleshooting =============== 1. If having memory allocation errors, try rebooting fresh, and putting this into /etc/sysctl.conf (or the corresponding /proc filessystem config under /proc/vm/min_free_kbytes doing 'echo 16384 > /proc/vm/min_free_kbytes`)... #for making ivtv happier with memory usage: vm.min_free_kbytes=16384 2. Always reboot cold when troubleshooting, the card will keep settings over normal reboots 3. The framebuffer will not allow direct writing safely, it will mess up encoding and decoding, usually making the chip inoperable until another reboot. ivtv-utils-1.4.1/doc/README.radio0000664000076400007640000000634011355717530015061 0ustar andyandyREADME for the IVTV Radio Support Hans Verkuil (hverkuil@xs4all.nl) Usage info for new version added by Adam Forsyth (agforsyth@gmail.com) Introduction ============ This document describes the ivtv PVR-350 radio support and the (very) simple radio utility. The ivtv driver supports only the v4l2 API for the radio functionality, so you need to find a radio application that can use that API. My experience with several of the radio applications is that they are either too old (i.e. they only support v4l), cannot do the simplest task (scanning for stations) properly, or tend to crash a lot. I've added a very simple radio utility that at least supports v4l2 and doesn't crash. Usage: ivtv-radio Possible options are: -d Radio control device (default: /dev/radio0) -s Scan for channels -a Scan for frequencies Use if Scan for channels is missing stuff If e.g. 90.9, 91.1, 91.3 all exist use this -f Tune to a specific frequency -j Just tune (don't try to play the audio) You'll have to play the audio yourself (see README.radio) -P Use passthrough mode of card -g Enable channel changing for passthrough mode -h Display this help message -i PCM audio capture device (default: /dev/video24) -c Command to play audio. This will be processed by the shell, after substituting %s with the audio device. Default: "aplay -f dat < %s" Some examples: ivtv-radio -s Scans for channels. ivtv-radio -f 93.1 Plays the specified frequency with aplay. ivtv-radio -f 93.1 -P -g Outputs the sound through the card audio out and give you a prompt allowing you to change frequencies. ivtv-radio -f 93.1 -j -g Gives you a prompt allowing you to change frequencies, but lets you play the sound with whatever program you want to use. When you press Ctrl-C to stop the radio utility you will get the sound of the current TV channel instead. On rare occasions I've seen read errors when trying to read from /dev/video24. Using 'cat /dev/video16' for a few seconds seems to fix the problem and I can use /dev/video24 again. If you use the '-g' option and you select an out-of-range frequency (e.g. 0), then for some reason changing to a valid frequency will fail. The only solution I know is to break off the radio application and start it again. There is still something strange in the radio tuner support. Driver Implementation Details ============================= The tuner in the ivtv cards has to be switched from TV to FM mode, which means that it is not possible to listen to the radio and watch TV at the same time. So, when you open the /dev/radio0 device the tuner is switched to FM mode, and after closing it it goes back to TV mode. You can open the radio device only once, the second time it will return EBUSY (just like the bttv driver). The last selected TV and radio frequencies are remembered and restored when closing/opening the radio device. ivtv-utils-1.4.1/doc/README.lirc0000664000076400007640000001366211355717530014721 0ustar andyandyREADME for IVTV Lirc support Introduction ============ Remote controls and IR receivers are supported by the IVTV driver for several cards, such as the Hauppauge PVR 250 and 350. You will need to setup LIRC 0.7.0 in order to use this support. Much of the information here came from: http://www.mythtv.org/docs/mythtv-HOWTO-22.html#ss22.2 Installation ============ 1. Make sure your kernel was built with "Character Devices | Standard/generic (8250/16550 and compatible UARTs) serial support" as a module, rebuilding the kernel if necessary. 2. Many distributions come with an outdated version of LIRC. You'll need to remove it. Find all the relevant binaries: # updatedb # locate lirc_i2c|grep `uname -r` # locate lirc_dev|grep `uname -r` # locate irw|grep "/usr" # locate lircd|grep "/usr" # locate irxevent|grep "/usr" And delete any LIRC code files, LIRC code directories, and LIRC binaries. 3. Download and untar the latest version of LIRC: # wget http://lirc.sourceforge.net/software/snapshots/lirc-0.7.0pre6.tar.bz2 # tar -xjf lirc-0.7.0pre6.tar.bz2 # cd lirc-0.7.0pre6 4. Compile and Install # ./setup.sh Select "1" (Driver configuration), then scroll down to "5" (TV Card), press ENTER, then scroll down to "f" (Hauppauge TV card) and press ENTER again. Once back at the main menu, press "3" for Save and run configure. # make # make install # depmod -ae 5. Update your /etc/modules.conf (or /etc/modutils/ivtv), adding the following lines if they don't exist: alias char-major-61 lirc_i2c add above ivtv lirc_dev lirc_i2c Then run: # update-modules (only if you're using modutils) # depmod -ae 6. Start lircd and startup ivtv. Lircd must be running for your remote to work, so you'll want to make sure this gets started at boot time via your system's init scripts. # /usr/local/sbin/lircd # modprobe ivtv Troubleshooting =============== -------- ISSUE: compile error stating: lirc_i2c.c:296: unknown field 'owner' specified in initializer SOLUTION: edit the file and comment out a line in the source code. See message http://www.gossamer-threads.com/lists/mythtv/users/40136 for detailed instructions. -------- ISSUE: LIRC devices and drivers not installed properly DIAGNOSTIC: As a part of the make install process, LIRC will create the appropriate device for you in /dev. Check to make sure: # ls -l /dev/lirc* crw-r--r-- 1 root root 61, 0 Sep 18 15:36 /dev/lirc srw-rw-rw- 1 root root 0 Sep 18 15:38 /dev/lircd= After modprobe-ing the lirc_i2c driver and runing the lircd program, check your /var/log/messages and /var/log/lircd files. # modprobe lirc_i2c # lsmod Module Size Used by Not tainted lirc_i2c 5124 0 lirc_dev 10096 1 [lirc_i2c] ... # lircd # tail /var/log/messages Sep 18 15:38:26 frontend kernel: lirc_i2c: chip found @ 0x18 (Hauppauge IR) Sep 18 15:38:26 frontend kernel: lirc_dev: lirc_register_plugin:sample_rate: 10 ... # tail /var/log/lircd Sep 18 15:24:52 frontend lircd 0.7.0pre2: lircd(hauppauge) ready -------- ISSUE: Your remote control is not working. DIAGNOSTIC: run the irw program and start pressing buttons. If nothing is happening, you must begin troubleshooting. SOLUTIONS: * Are there batteries in the remote? * Does the remote work? You may be able to see the flashes of IR coming from the remote if you look at it with a video camera. * Is the IR dongle cable plugged in? * Did you remove all of the old LIRC device drivers? Run "updatedb" as root, then "locate lirc_i2c". The only lirc_i2c should be the one in the misc/ directory for your kernel version. * Did you run depmod? * Is your modules.conf setup correctly? * Did you modprobe lirc_i2c? * Did you run lircd? * Do you have an /etc/lircd.conf? * Is /dev/lirc a character mode file, major 61, minor 0? Is it readable by all groups? * If you think you may have had old LIRC device drivers you may need to reboot to ensure that they're totally out of the system. Try running modprobe -r lirc_i2c as root first, then modprobe lirc_i2c and try again. * What path does modinfo lirc_i2c and modinfo lirc_dev show? It should be in /lib/modules/{your kernel version}/misc/ If none of the above works, and irw still isn't showing keypresses, then you will need to ask your question on the LIRC list: http://lists.sourceforge.net/lists/listinfo/lirc-list LIRC & MythTV ============= There are two options for using LIRC with MythTV: via MythTV's native support or via irxevent Option 1: MythTV Native Support ------------------------------- edit MythTV's settings.pro, making sure the following comments are uncommented: # Native lirc support CONFIG += using_lirc LIRC_LIBS = -llirc_client Then recompile and install Myth: $ make distclean; make $ su # make install Put the lirc rc file in the appropriate place in the mythtv user's home directory. It has a slightly different format than what you would use if you were using irxevent. Also note that it is in your .mythtv directory and does not have a "." in the filename. $ cp configfiles/hauppauge-lircrc-nativelirc ~mythtv/.mythtv/lircrc Option 2: irxevent/irexec Support --------------------------------- Ensure that the button names that come up with irw match the ones in the .lircrc file in your home directory. Note that if you are not using native LIRC support, the .lircrc file is in your home directory and has a "." as the first character. You will need to have irexec running when you use myth, so you might want to add it to your mythfrontend startup script. ivtv-utils-1.4.1/COPYING0000664000076400007640000004440311355717530013374 0ustar andyandy NOTE! This copyright does *not* cover user programs that use kernel services by normal system calls - this is merely considered normal use of the kernel, and does *not* fall under the heading of "derived work". Also note that the GPL below is copyrighted by the Free Software Foundation, but the instance of code that it refers to (the Linux kernel) is copyrighted by me and others who actually wrote it. Also note that the only valid version of the GPL as far as the kernel is concerned is _this_ particular version of the license (ie v2, not v2.2 or v3.x or whatever), unless explicitly otherwise stated. Linus Torvalds ---------------------------------------- GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. ivtv-utils-1.4.1/README0000664000076400007640000000175111355717530013220 0ustar andyandyThis is the README for the ivtv utilities package for use with kernels >= 2.6.29. See www.ivtvdriver.org for releases for older kernels. doc/ - contains documentation :) /README.install Installation info /README.devices /dev/xxxx devices /README.utils Included utilities /README.lirc Infrared remote control /README.vbi VBI (Teletext, widescreen, close captioning, etc.) /README.radio The FM Radio /video-quality.txt Some notes on video quality utils/ - some useful (and required) tools for managing the hardware test/ - some useful test tools for testing the hardware Also see: Homepage + Wiki http://www.ivtvdriver.org Subversion repository: http://ivtvdriver.org/svn/ivtv Download area: http://dl.ivtvdriver.org Mail Archives http://www.gossamer-threads.com/lists/ivtv/devel/ http://www.gossamer-threads.com/lists/ivtv/users/ IRC irc://irc.freenode.net/ivtv-dev Donations http://www.ivtvdriver.org/index.php/IVTV:Site_support ivtv-utils-1.4.1/utils/0000775000076400007640000000000011355717714013500 5ustar andyandyivtv-utils-1.4.1/utils/enc_chann.c0000664000076400007640000001772211355717530015565 0ustar andyandy/* Preliminary hack to change channels on ivtv driver Copyright (C) 2003-2004 Kevin Thayer This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #define __user #include #define VIDIOC_S_FREQUENCY2 0x402c5639 enum v4l2_tuner_type2 { __V4L2_TUNER_RADIO = 1, __V4L2_TUNER_ANALOG_TV = 2, }; struct v4l2_frequency2 { __u32 tuner; enum v4l2_tuner_type2 type; __u32 frequency; __u32 reserved[8]; }; unsigned long NTSC_BCAST[] = { 2, 55250, 3, 61250, 4, 67250, 5, 77250, 6, 83250, 7, 175250, 8, 181250, 9, 187250, 10, 193250, 11, 199250, 12, 205250, 13, 211250, 14, 471250, 15, 477250, 16, 483250, 17, 489250, 18, 495250, 19, 501250, 20, 507250, 21, 513250, 22, 519250, 23, 525250, 24, 531250, 25, 537250, 26, 543250, 27, 549250, 28, 555250, 29, 561250, 30, 567250, 31, 573250, 32, 579250, 33, 585250, 34, 591250, 35, 597250, 36, 603250, 37, 609250, 38, 615250, 39, 621250, 40, 627250, 41, 633250, 42, 639250, 43, 645250, 44, 651250, 45, 657250, 46, 663250, 47, 669250, 48, 675250, 49, 681250, 50, 687250, 51, 693250, 52, 699250, 53, 705250, 54, 711250, 55, 717250, 56, 723250, 57, 729250, 58, 735250, 59, 741250, 60, 747250, 61, 753250, 62, 759250, 63, 765250, 64, 771250, 65, 777250, 66, 783250, 67, 789250, 68, 795250, 69, 801250, 70, 807250, 71, 813250, 72, 819250, 73, 825250, 74, 831250, 75, 837250, 76, 843250, 77, 849250, 78, 855250, 79, 861250, 80, 867250, 81, 873250, 82, 879250, 83, 885250, 0, 0 }; unsigned long NTSC_CABLE[] = { 1, 73250, 2, 55250, 3, 61250, 4, 67250, 5, 77250, 6, 83250, 7, 175250, 8, 181250, 9, 187250, 10, 193250, 11, 199250, 12, 205250, 13, 211250, 14, 121250, 15, 127250, 16, 133250, 17, 139250, 18, 145250, 19, 151250, 20, 157250, 21, 163250, 22, 169250, 23, 217250, 24, 223250, 25, 229250, 26, 235250, 27, 241250, 28, 247250, 29, 253250, 30, 259250, 31, 265250, 32, 271250, 33, 277250, 34, 283250, 35, 289250, 36, 295250, 37, 301250, 38, 307250, 39, 313250, 40, 319250, 41, 325250, 42, 331250, 43, 337250, 44, 343250, 45, 349250, 46, 355250, 47, 361250, 48, 367250, 49, 373250, 50, 379250, 51, 385250, 52, 391250, 53, 397250, 54, 403250, 55, 409250, 56, 415250, 57, 421250, 58, 427250, 59, 433250, 60, 439250, 61, 445250, 62, 451250, 63, 457250, 64, 463250, 65, 469250, 66, 475250, 67, 481250, 68, 487250, 69, 493250, 70, 499250, 71, 505250, 72, 511250, 73, 517250, 74, 523250, 75, 529250, 76, 535250, 77, 541250, 78, 547250, 79, 553250, 80, 559250, 81, 565250, 82, 571250, 83, 577250, 84, 583250, 85, 589250, 86, 595250, 87, 601250, 88, 607250, 89, 613250, 90, 619250, 91, 625250, 92, 631250, 93, 637250, 94, 643250, 95, 91250, 96, 97250, 97, 103250, 98, 109250, 99, 115250, 100, 649250, 101, 655250, 102, 661250, 103, 667250, 104, 673250, 105, 679250, 106, 685250, 107, 691250, 108, 697250, 109, 703250, 110, 709250, 111, 715250, 112, 721250, 113, 727250, 114, 733250, 115, 739250, 116, 745250, 117, 751250, 118, 757250, 119, 763250, 120, 769250, 121, 775250, 122, 781250, 123, 787250, 124, 793250, 125, 799250, 0, 0 }; unsigned long NTSC_HRC[] = { 1, 72000, 2, 54000, 3, 60000, 4, 66000, 5, 78000, 6, 84000, 7, 174000, 8, 180000, 9, 186000, 10, 192000, 11, 198000, 12, 204000, 13, 210000, 14, 120000, 15, 126000, 16, 132000, 17, 138000, 18, 144000, 19, 150000, 20, 156000, 21, 162000, 22, 168000, 23, 216000, 24, 222000, 25, 228000, 26, 234000, 27, 240000, 28, 246000, 29, 252000, 30, 258000, 31, 264000, 32, 270000, 33, 276000, 34, 282000, 35, 288000, 36, 294000, 37, 300000, 38, 306000, 39, 312000, 40, 318000, 41, 324000, 42, 330000, 43, 336000, 44, 342000, 45, 348000, 46, 354000, 47, 360000, 48, 366000, 49, 372000, 50, 378000, 51, 384000, 52, 390000, 53, 396000, 54, 402000, 55, 408000, 56, 414000, 57, 420000, 58, 426000, 59, 432000, 60, 438000, 61, 444000, 62, 450000, 63, 456000, 64, 462000, 65, 468000, 66, 474000, 67, 480000, 68, 486000, 69, 492000, 70, 498000, 71, 504000, 72, 510000, 73, 516000, 74, 522000, 75, 528000, 76, 534000, 77, 540000, 78, 546000, 79, 552000, 80, 558000, 81, 564000, 82, 570000, 83, 576000, 84, 582000, 85, 588000, 86, 594000, 87, 600000, 88, 606000, 89, 612000, 90, 618000, 91, 624000, 92, 630000, 93, 636000, 94, 642000, 95, 900000, 96, 960000, 97, 102000, 98, 108000, 99, 114000, 100, 648000, 101, 654000, 102, 660000, 103, 666000, 104, 672000, 105, 678000, 106, 684000, 107, 690000, 108, 696000, 109, 702000, 110, 708000, 111, 714000, 112, 720000, 113, 726000, 114, 732000, 115, 738000, 116, 744000, 117, 750000, 118, 756000, 119, 762000, 120, 768000, 121, 774000, 122, 780000, 123, 786000, 124, 792000, 125, 798000, 0, 0 }; unsigned long NTSC_BCAST_JP[] = { 1, 91250, 2, 97250, 3, 103250, 4, 171250, 5, 177250, 6, 183250, 7, 189250, 8, 193250, 9, 199250, 10, 205250, 11, 211250, 12, 217250, 13, 471250, 14, 477250, 15, 483250, 16, 489250, 17, 495250, 18, 501250, 19, 507250, 20, 513250, 21, 519250, 22, 525250, 23, 531250, 24, 537250, 25, 543250, 26, 549250, 27, 555250, 28, 561250, 29, 567250, 30, 573250, 31, 579250, 32, 585250, 33, 591250, 34, 597250, 35, 603250, 36, 609250, 37, 615250, 38, 621250, 39, 627250, 40, 633250, 41, 639250, 42, 645250, 43, 651250, 44, 657250, 45, 663250, 46, 669250, 47, 675250, 48, 681250, 49, 687250, 50, 693250, 51, 699250, 52, 705250, 53, 711250, 54, 717250, 55, 723250, 56, 729250, 57, 735250, 58, 741250, 59, 747250, 60, 753250, 61, 759250, 62, 765250, 0, 0 }; unsigned long NTSC_CABLE_JP[] = { 13, 109250, 14, 115250, 15, 121250, 16, 127250, 17, 133250, 18, 139250, 19, 145250, 20, 151250, 21, 157250, 22, 165250, 23, 223250, 24, 231250, 25, 237250, 26, 243250, 27, 249250, 28, 253250, 29, 259250, 30, 265250, 31, 271250, 32, 277250, 33, 283250, 34, 289250, 35, 295250, 36, 301250, 37, 307250, 38, 313250, 39, 319250, 40, 325250, 41, 331250, 42, 337250, 43, 343250, 44, 349250, 45, 355250, 46, 361250, 47, 367250, 48, 373250, 49, 379250, 50, 385250, 51, 391250, 52, 397250, 53, 403250, 54, 409250, 55, 415250, 56, 421250, 57, 427250, 0, 0 }; int chanf(int fd, int frequency) { int retval; struct v4l2_frequency2 vf; frequency = (int)((frequency * 16) / 1000); /* was /1000 */ vf.tuner = 0; vf.type = V4L2_TUNER_ANALOG_TV; vf.frequency = frequency; retval = ioctl(fd, VIDIOC_S_FREQUENCY2, &vf); if (retval) { printf("ioctl for frequency %d failed", frequency); return 1; } return 0; } int chann(int fd, int channel) { int retval; unsigned long chann, freq, c, f, *array; /* Pick your TV standard here! */ array = NTSC_CABLE; chann = (unsigned long)channel; freq = 0; while (*array != 0) { c = *(array++); f = *(array++); if (chann == c) { printf("found channel %d at %d\n", (int)c, (int)f); freq = (int)f; break; } } if (freq == 0) { printf("channel %d invalid or not found in this standard\n", (int)chann); return -1; } retval = chanf(fd, freq); if (retval) { printf("failed to set channel %d", channel); return 1; } return 0; } ivtv-utils-1.4.1/utils/encoder.h0000664000076400007640000000527511355717530015275 0ustar andyandy/* Copyright (C) 2004 Chris Kennedy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __ENCODER_H #define __ENCODER_H int setup_encoder(int dev, int settings[]); /* Encoder Settings */ #define BFRAMES 3 #define GOPCL 1 int setup_encoder(int fd, int settings[]) { struct ivtv_ioctl_codec in_codec; struct v4l2_control ctrl; /* set_ctrl/get_ctrls */ /* Open Device */ if (fd < 0) { fprintf(stderr, "Device not open\n"); return -1; } /* Setup Brightness, Contrast, Saturation, Hue */ ctrl.id = V4L2_CID_BRIGHTNESS; ctrl.value = settings[11]; if (ioctl(fd, VIDIOC_S_CTRL, &ctrl) < 0) fprintf(stderr, "ioctl: VIDIOC_S_CTRL failed\n"); ctrl.id = V4L2_CID_CONTRAST; ctrl.value = settings[12]; if (ioctl(fd, VIDIOC_S_CTRL, &ctrl) < 0) fprintf(stderr, "ioctl: VIDIOC_S_CTRL failed\n"); ctrl.id = V4L2_CID_SATURATION; ctrl.value = settings[13]; if (ioctl(fd, VIDIOC_S_CTRL, &ctrl) < 0) fprintf(stderr, "ioctl: VIDIOC_S_CTRL failed\n"); ctrl.id = V4L2_CID_HUE; ctrl.value = settings[14]; if (ioctl(fd, VIDIOC_S_CTRL, &ctrl) < 0) fprintf(stderr, "ioctl: VIDIOC_S_CTRL failed\n"); /* Setup Input Port */ if (ioctl(fd, VIDIOC_S_INPUT, &settings[15]) < 0) fprintf(stderr, "ioctl: VIDIOC_S_INPUT failed\n"); /* Setup Codecs */ if (ioctl(fd, IVTV_IOC_G_CODEC, &in_codec) < 0) fprintf(stderr, "ioctl: IVTV_IOC_G_CODEC failed\n"); else { in_codec.aspect = settings[0]; in_codec.bitrate_mode = settings[1]; in_codec.bitrate = settings[2]; in_codec.bitrate_peak = settings[3]; in_codec.stream_type = settings[4]; in_codec.audio_bitmask = settings[5]; in_codec.dnr_mode = settings[6]; in_codec.dnr_type = settings[7]; in_codec.dnr_spatial = settings[8]; in_codec.dnr_temporal = settings[9]; in_codec.pulldown = settings[10]; in_codec.framerate = settings[16]; in_codec.framespergop = settings[17]; in_codec.bframes = BFRAMES; in_codec.gop_closure = GOPCL; if (ioctl(fd, IVTV_IOC_S_CODEC, &in_codec) < 0) fprintf(stderr, "ioctl: IVTV_IOC_S_CODEC failed\n"); } return 0; } #endif ivtv-utils-1.4.1/utils/enc_mindex.c0000664000076400007640000003355311355717530015762 0ustar andyandy//++MTY use e.g., mpegcat -dV /video/1011_20030808233000_20030809000000.nuv /* # # MPEG2Parser class testing tool # # $Id: mindex.c,v 1.8 2003/12/16 18:50:56 root Exp root $ # # Copyright (C) 2001-2003 Kees Cook # kees@outflux.net, http://outflux.net/ # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # http://www.gnu.org/copyleft/gpl.html # */ /* * buffer management inspired by mplayer */ #define _FILE_OFFSET_BITS 64 #include #include #include #include #include #include #include #include #include #include #include #include #include "mpeg2structs.h" #define VERBOSE 0 #define STATUS 1 int mindex(char *, char *, char *); // general stuff int debug = 0; int dvd_names = 0; // file position options loff_t begin_at = 0; loff_t num_bytes = 0; typedef enum { PACK_NONE, PACK_SPECIAL, PACK_PES_SIMPLE, // packet length == data length PACK_PES_COMPLEX, // crazy headers need skipping } packet_type; typedef enum { SUBID_NONE, // no sub id (sid=0) SUBID_DATA, // first PES data byte } subid_type; // FIXME: // - add "valid scope" flags (eg some markers only valid in Video stream) // - add "struct size" field for auto-forwarding past each marker typedef struct { // the byte value match for the packet tags uint8_t code_match_lo; // low end of the range of matches uint8_t code_match_hi; // high end of the range of matches // what kind of PES is it? packet_type packet; // how do we find the stream sub id subid_type subid_method; // misc stuff... sorting types? } packet_tag_info; packet_tag_info packet_tags[] = { {0x00, 0x00, PACK_SPECIAL, SUBID_NONE}, // pic start {0x01, 0xAF, PACK_SPECIAL, SUBID_NONE}, // video slices {0xB0, 0xB1, PACK_SPECIAL, SUBID_NONE}, // reserved {0xB2, 0xB5, PACK_SPECIAL, SUBID_NONE}, // user data, sequences {0xB6, 0xB6, PACK_SPECIAL, SUBID_NONE}, // reserved {0xB7, 0xB9, PACK_SPECIAL, SUBID_NONE}, // sequence, gop, end {0xBA, 0xBA, PACK_SPECIAL, SUBID_NONE}, // pack {0xBB, 0xBB, PACK_PES_SIMPLE, SUBID_NONE}, // system: same len as PES {0xBC, 0xBC, PACK_PES_SIMPLE, SUBID_NONE}, // PES: prog stream map {0xBD, 0xBD, PACK_PES_COMPLEX, SUBID_DATA}, // PES: priv 1 {0xBE, 0xBF, PACK_PES_SIMPLE, SUBID_NONE}, // PES: padding, priv 2 {0xC0, 0xDF, PACK_PES_COMPLEX, SUBID_NONE}, // PES: Audio {0xE0, 0xEF, PACK_PES_COMPLEX, SUBID_NONE}, // PES: Video {0xF0, 0xF2, PACK_PES_SIMPLE, SUBID_NONE}, // PES: ecm, emm, dsmcc {0xF3, 0xF7, PACK_PES_COMPLEX, SUBID_NONE}, // PES: iso 13522/h2221a-d {0xF8, 0xF8, PACK_PES_SIMPLE, SUBID_NONE}, // PES: h2221e {0xF9, 0xF9, PACK_PES_COMPLEX, SUBID_NONE}, // PES: ancillary {0xFA, 0xFE, PACK_PES_SIMPLE, SUBID_NONE}, // PES: reserved {0xFF, 0xFF, PACK_PES_SIMPLE, SUBID_NONE}, // PES: prog stream dir {0, 0, PACK_NONE, SUBID_NONE} // end of list }; #define BUFFER_SIZE (1024*512) FILE *fp = NULL; uint8_t buffer[BUFFER_SIZE]; loff_t offset = 0; size_t buffer_min = 0; size_t buffer_max = 0; loff_t buffer_tell() { return offset - buffer_max + buffer_min; } // can point to a file offset to refill from void buffer_refill() { size_t got; //fprintf(stderr,"filling...\n"); if (buffer_min < buffer_max) { memmove(buffer, buffer + buffer_min, buffer_max - buffer_min); } buffer_max -= buffer_min; buffer_min = 0; got = fread(buffer + buffer_max, sizeof(uint8_t), BUFFER_SIZE - buffer_max, fp); if (got < 0) { perror("fread"); exit(2); } offset += got; buffer_max += got; //fprintf(stderr,"bump %d more\n",got); usleep(1); } void buffer_seek(loff_t location) { // is this location within our current buffer? if (location < offset && location >= buffer_tell()) { buffer_min += location - buffer_tell(); } else { // outside: clear the buffer buffer_min = buffer_max = 0; // clear buffer offset = location; if (fseeko(fp, offset, SEEK_SET) < 0) { fprintf(stderr, "fseeko failed: err = %s\n", strerror(errno)); exit(1); } } //don't do this... way too slow //buffer_refill(); } int buffer_start(char *filename) { if (fp) fclose(fp); fp = NULL; if (!(fp = fopen(filename, "r"))) { perror(filename); return -1; } offset = 0; buffer_min = 0; buffer_max = 0; return 0; } int buffer_get_byte(uint8_t * byte) { if (!byte) return -2; if (buffer_min == buffer_max) buffer_refill(); if (buffer_min == buffer_max) return -1; *byte = buffer[buffer_min++]; return 0; } int buffer_look_ahead(uint8_t * bytes, int count) { int i; if (!bytes) return -2; if (count <= 0) return 0; if (count >= BUFFER_SIZE) return -3; if (buffer_min + count > buffer_max) buffer_refill(); if (buffer_min + count > buffer_max) return -1; for (i = 0; i < count; i++) { *(bytes++) = buffer[buffer_min + i]; //fprintf(stderr,"\tsaw: 0x%02X\n",buffer[buffer_min+i]); } return 0; } uint8_t packet_buffer[65536]; // max size of a double byte uint8_t *packet_start; uint16_t packet_size; loff_t file_offset_of_last_packet = 0; uint32_t framecount = 0; typedef union { struct { uint32_t padding:5, broken:1, closed:1, frame:6, second:6, padding2:1, minute:6, hour:5, drop:1; }; struct { uint32_t data; }; } gop_header_t; struct mpeg_index_entry { unsigned int frame; gop_header_t timestamp; unsigned long long offset; }; FILE *indexfd = NULL; struct mpeg_index_entry last_index_written; int last_was_gop_packet = 0; static inline uint32_t bswap(uint32_t x) { asm("bswap %0": "=r"(x):"0"(x)); return x; } char *timestamp_to_string(char *str, gop_header_t timestamp) { static char buf[256]; char *p = (str) ? str : buf; snprintf(p, sizeof(buf), "%d:%02d:%02d:%d", timestamp.hour, timestamp.minute, timestamp.second, timestamp.frame); return p; } static inline gop_header_t make_timestamp(int hour, int minute, int second, int frame) { gop_header_t gop; gop.hour = hour; gop.minute = minute; gop.second = second; gop.frame = frame; return gop; } loff_t process_packet(uint8_t code, char *bstatus) { uint8_t bytes[32]; int i; unsigned int length, header_len; loff_t position = 0; //unsigned long long system_clock_ref_base; // "H"igh, "M"edium, "L"ow bits //unsigned long system_clock_ref_ext; // "E" //unsigned int program_mux_rate; // "R" //unsigned int pack_stuffing_length; // "S" loff_t file_offset = buffer_tell() - 4; // initialize "unknown" packet length header_len = length = 0; last_was_gop_packet = 0; // find the packet type for (i = 0; packet_tags[i].packet != PACK_NONE; i++) { if (code >= packet_tags[i].code_match_lo && code <= packet_tags[i].code_match_hi) { int sid = 0; switch (packet_tags[i].packet) { case PACK_SPECIAL: // actually, nothing special break; case PACK_PES_SIMPLE: case PACK_PES_COMPLEX: if (packet_tags[i].packet == PACK_PES_COMPLEX) { if (buffer_look_ahead(bytes, 5) != 0) return 0; header_len = 5 + bytes[4]; if (dvd_names && packet_tags[i].subid_method == SUBID_DATA && buffer_look_ahead(bytes, header_len + 1) == 0) { sid = bytes[header_len]; } } else { if (buffer_look_ahead(bytes, 2) != 0) return 0; } length = bytes[1] | (bytes[0] << 8); // get position updated for next packet location if ((code & PES_TYPE_MASK_video) == PES_TYPE_video) break; // skip position update position = buffer_tell() + length + 2; break; default: case PACK_NONE: // FIXME: not possible! break; } break; // found a match } } if (code == PES_TYPE_pack_start) { //++MTY file_offset_of_last_packet = file_offset; if (buffer_look_ahead(bytes, 10) == 0) { //| 0 | 1 | 2 | 3 | 4 | 5 | 6 | // 76543210765432107654321076543210765432107654321076543210 // xxHHHxMMMMMMMMMMMMMMMxLLLLLLLLLLLLLLLxEEEEEEEEExRRRRRRRR // 333 222222222211111 111110000000000 000000000 22111111// bit // 210 987654321098765 432109876543210 876543210 10987654// number // - - - - - - - - - - // 2 2 2 1 1 0 - 0 - 1// left // 7 8 0 2 3 5 3 7 1 4// shift // //| 7 | 8 | 9 | // 765432107654321076543210 // RRRRRRRRRRRRRRxxrrrrrSSS // 11110000000000 00000000 // bit // 32109876543210 43210210 // number // - - - - // 0 - - 0 // left // 6 2 3 0 // shift /*int system_clock_ref_base = (((bytes[0] & 0x38) << 27) | ((bytes[0] & 0x03) << 28) | ((bytes[1] & 0xFF) << 20) | ((bytes[2] & 0xF8) << 12) | ((bytes[2] & 0x03) << 13) | ((bytes[3] & 0xFF) << 5) | ((bytes[4] & 0xF8) >> 3)); int system_clock_ref_ext = (((bytes[4] & 0x03) << 7) | ((bytes[5] & 0xFE) >> 1)); int program_mux_rate = (((bytes[6] & 0xFF) << 14) | ((bytes[7] & 0xFF) << 6) | ((bytes[8] & 0xFC) >> 2)); int pack_stuffing_length = (bytes[9] & 0x07); */ //sprintf(answer, "Pack Start (Mux Rate: %u Stuffing: %u)", // FIXME: too many damn bits // system_clock_ref_base, // system_clock_ref_ext, //program_mux_rate, pack_stuffing_length); //return answer; } else { //return "Pack Start (incomplete flags)"; } } else if (code == PES_TYPE_group_start) { //if (buffer_look_ahead(bytes, 4) == 0) { gop_header_t gop; if (buffer_look_ahead((uint8_t *)&gop, sizeof(gop)) == 0) { gop.data = bswap(gop.data); /* int drop = ((bytes[0] & 0x80) > 0); int hour = ((bytes[0] & 0x7C) >> 2); int min = ((bytes[0] & 0x3) << 4) | ((bytes[1] & 0xF0) >> 4); int sec = ((bytes[1] & 0x7) << 3) | ((bytes[2] & 0xE0) >> 6); int pictures = ((bytes[2] & 0x3F) << 1) | ((bytes[3] & 0x80) >> 7); int closed = ((bytes[3] & 0x40) > 0); int broken = ((bytes[3] & 0x20) > 0); */ /* sprintf(answer, " GOP Start (%02d:%02d:%02d.%02d%s%s%s)", hour, min, sec, pictures, drop ? " drop" : "", closed ? " closed" : " open", broken ? " broken" : ""); */ gop.padding2 = gop.padding = gop.closed = gop.broken = gop.drop = 0; last_index_written.frame = framecount; last_index_written.timestamp = gop; //((unsigned long long)((gop.hour * (60*60)) + (gop.minute*60) + gop.second) << 32LL) + gop.frame; last_index_written.offset = file_offset_of_last_packet; if (indexfd) fwrite(&last_index_written, sizeof(last_index_written), 1, indexfd); last_was_gop_packet = 1; if (VERBOSE) { fprintf(stderr, "==> % 15lld: GOP 0x%08x (%02d:%02d:%02d.%02d) on frame %d; %s %s %s\n", (long long)file_offset_of_last_packet, (int)(last_index_written.timestamp. data), gop.hour, gop.minute, gop.second, gop.frame, framecount, (gop.closed) ? "closed" : "", (gop.broken) ? "broken" : "", (gop.drop) ? "drop" : ""); } /* Write out Status to LOCK */ if (STATUS == 1 && bstatus != NULL) { FILE *lck = NULL; lck = fopen(bstatus, "w"); if (lck != NULL) { /* Write PID to LOCK */ fprintf(lck, "% 15lld: GOP 0x%08x %02d:%02d:%02d.%02d frame %d; %s %s %s\n", (long long)file_offset_of_last_packet, (int)(last_index_written. timestamp.data), gop.hour, gop.minute, gop.second, gop.frame, framecount, (gop.closed) ? "closed" : "", (gop.broken) ? "broken" : "", (gop.drop) ? "drop" : ""); fclose(lck); } } } else { //return " GOP Start (incomplete flags)"; } } else if (code == PES_TYPE_picture_start) { framecount++; } return position; } int mindex(char *i_mpeg, char *o_index, char *bstatus) { uint32_t marker; uint8_t byte; int running = 1; if (i_mpeg == NULL || o_index == NULL) { fprintf(stderr, "mpegindex: Syntax is mpegindex mpegfile indexfile\n\n"); return -1; } indexfd = fopen(o_index, "w"); if (!indexfd) { fprintf(stderr, "mpegindex: Error: cannot create index file %s.\n", o_index); return -2; } if (buffer_start(i_mpeg) < 0) { fprintf(stderr, "mpegindex: Error: cannot open mpeg file %s.\n", i_mpeg); return -3; } buffer_seek(begin_at); marker = 0xFFFFFFFF; while (running) { //fprintf(stderr,"%08X\n",marker); if ((marker & 0xFFFFFF00) == 0x100) { loff_t newpos = process_packet(byte, bstatus); // we skipped to a new location? if (newpos != 0) { //fprintf(stdout,"skipping to %" OFF_T_FORMAT "\n",newpos); marker = 0xFFFFFFFF; buffer_seek(newpos); } } marker <<= 8; if (buffer_get_byte(&byte) < 0) { //running = 0; } else marker |= byte; if (num_bytes && buffer_tell() - begin_at > num_bytes) { //running = 0; } /*if (last_was_gop_packet && ((last_index_written.timestamp.second % 30) == 0)) { fprintf(stdout, "\r%s: Processed frame %d at %s (file offset %lld)", i_mpeg, last_index_written.frame, timestamp_to_string(NULL, last_index_written.timestamp), last_index_written.offset); fflush(stdout); } */ } fprintf(stdout, "\r%s: Processed %d frames covering time %s (file size %lld)\n\n", i_mpeg, last_index_written.frame, timestamp_to_string(NULL, last_index_written. timestamp), last_index_written.offset); fclose(indexfd); return 0; } ivtv-utils-1.4.1/utils/ivtv-tune/0000775000076400007640000000000011355717714015441 5ustar andyandyivtv-utils-1.4.1/utils/ivtv-tune/ivtv-tune.c0000664000076400007640000001170411355717530017545 0ustar andyandy/* Channel/Frequency changer for V4L2 compatible video encoders Copyright © 2005 Tyler Trafford inspired by ptune.pl from James A. Pattie frequencies.{c,h} are © Nathan Laredo parseconfig.{c,h} are from xawtv v3.94 http://linux.bytesex.org/xawtv/ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include #include #define __user #include #include #include #include #include #include #include #include "xawtv_parseconfig.h" #include "frequencies.h" #include "cmdline.h" int setfreq(char *device, int frequency); int getfreqvalue(char *freqtable, char *channel); int getxawvalue(char *xawchannel); int main(int argc, char *argv[]) { struct gengetopt_args_info opt; struct stat buf; FILE *fp = NULL; int i, j; char *homedir = getenv("HOME"); if (homedir) { char *config = (char*)malloc(strlen(homedir) + strlen("/.ivtv-tune") + 1); sprintf(config, "%s/.ivtv-tune", homedir); // create config file, if it doesn't already exist if (stat(config, &buf) != 0) { fp = fopen(config, "w"); fprintf(fp, "device /dev/video0\nfreqtable us-cable\n"); fclose(fp); } cmdline_parser(argc, argv, &opt); cmdline_parser_configfile(config, &opt, 0, 0, 0); free(config); } else cmdline_parser(argc, argv, &opt); if (opt.device_given) { // tune to user-supplied frequency if (opt.frequency_given) { return setfreq(opt.device_arg, (int)(opt.frequency_arg*1000)); } // tune to user-supplied channel if (opt.channel_given && opt.freqtable_given) { i = getfreqvalue(opt.freqtable_arg, opt.channel_arg); if (!i) { printf("Invalid channel for '%s'\n", opt.freqtable_arg); return 1; } return setfreq(opt.device_arg, i); } // tune to channel which exists in ~/.xawtv if (opt.xawtv_given) { i = getxawvalue(opt.xawtv_arg); if (i < 0) { printf("Channel '%s' not defined in .xawtv\n", opt.xawtv_arg); return 1; } return setfreq(opt.device_arg, i); } } // list all channels in current frequency table if (opt.list_channels_given && opt.freqtable_given) { fprintf(stderr, "Channels/Frequencies (MHz) for \'%s\':\n", opt.freqtable_arg); for (i = 0; (chanlists[i].name != NULL) && strcmp(chanlists[i].name, opt.freqtable_arg) != 0; i++); for (j = 0; j < chanlists[i].count; j++) { printf("%s\t%.3f\n", chanlists[i].list[j].name, chanlists[i].list[j].freq/1000.0); } return 0; } // list all available frequency tables if (opt.list_freqtable_given) { fprintf(stderr, "Frequency Maps:\n"); for (i = 0; chanlists[i].name != NULL; i++) printf("%s\n", chanlists[i].name); return 0; } cmdline_parser_print_help(); return 0; } int setfreq(char *device, int frequency) { struct v4l2_frequency vf; struct v4l2_tuner vt; int fd, result; if ((fd = open(device, O_RDWR)) < 0) { fprintf(stderr, "Failed to open %s\n", device); return 1; } vf.tuner = 0; vf.type = V4L2_TUNER_ANALOG_TV; vf.frequency = (frequency * 16)/1000; result = ioctl(fd, VIDIOC_S_FREQUENCY, &vf); vt.index = 0; result = ioctl(fd, VIDIOC_G_TUNER, &vt); close(fd); if (result < 0) { fprintf(stderr, "ioctl VIDIOC_S_FREQUENCY failed\n"); return 1; } printf("%s: %.3f MHz", device, frequency/1000.0); if (vt.signal) printf(" (Signal Detected)"); printf("\n"); return 0; } int getfreqvalue(char *freqtable, char *channel) { int i, j; for (i = 0; (chanlists[i].name != NULL) && strcmp(chanlists[i].name, freqtable) != 0; i++); for (j = 0; (j < chanlists[i].count) && strcmp(chanlists[i].list[j].name, channel) != 0; j++); if (j == chanlists[i].count) return 0; return chanlists[i].list[j].freq; } int getxawvalue(char *xawchannel) { char *homedir = getenv("HOME"); if (!homedir) return -1; char *xawtv = (char*)malloc(strlen(homedir) + strlen("/.xawtv") + 1); char *channel, *freqtable; sprintf(xawtv, "%s/.xawtv", homedir); cfg_parse_file(xawtv); free(xawtv); channel = cfg_get_str(xawchannel, "channel"); if (channel) { freqtable = cfg_get_str("global", "freqtab"); return getfreqvalue(freqtable, channel); } return cfg_get_float(xawchannel, "freq") * 1000; } ivtv-utils-1.4.1/utils/ivtv-tune/frequencies.c0000664000076400007640000007267111355717530020127 0ustar andyandy#include #include #include #include "frequencies.h" /* --------------------------------------------------------------------- */ /* US broadcast */ static struct CHANLIST ntsc_bcast[] = { { "2", 55250 }, { "3", 61250 }, { "4", 67250 }, { "5", 77250 }, { "6", 83250 }, { "7", 175250 }, { "8", 181250 }, { "9", 187250 }, { "10", 193250 }, { "11", 199250 }, { "12", 205250 }, { "13", 211250 }, { "14", 471250 }, { "15", 477250 }, { "16", 483250 }, { "17", 489250 }, { "18", 495250 }, { "19", 501250 }, { "20", 507250 }, { "21", 513250 }, { "22", 519250 }, { "23", 525250 }, { "24", 531250 }, { "25", 537250 }, { "26", 543250 }, { "27", 549250 }, { "28", 555250 }, { "29", 561250 }, { "30", 567250 }, { "31", 573250 }, { "32", 579250 }, { "33", 585250 }, { "34", 591250 }, { "35", 597250 }, { "36", 603250 }, { "37", 609250 }, { "38", 615250 }, { "39", 621250 }, { "40", 627250 }, { "41", 633250 }, { "42", 639250 }, { "43", 645250 }, { "44", 651250 }, { "45", 657250 }, { "46", 663250 }, { "47", 669250 }, { "48", 675250 }, { "49", 681250 }, { "50", 687250 }, { "51", 693250 }, { "52", 699250 }, { "53", 705250 }, { "54", 711250 }, { "55", 717250 }, { "56", 723250 }, { "57", 729250 }, { "58", 735250 }, { "59", 741250 }, { "60", 747250 }, { "61", 753250 }, { "62", 759250 }, { "63", 765250 }, { "64", 771250 }, { "65", 777250 }, { "66", 783250 }, { "67", 789250 }, { "68", 795250 }, { "69", 801250 }, { "70", 807250 }, { "71", 813250 }, { "72", 819250 }, { "73", 825250 }, { "74", 831250 }, { "75", 837250 }, { "76", 843250 }, { "77", 849250 }, { "78", 855250 }, { "79", 861250 }, { "80", 867250 }, { "81", 873250 }, { "82", 879250 }, { "83", 885250 }, }; /* US cable */ static struct CHANLIST ntsc_cable[] = { { "1", 73250 }, { "2", 55250 }, { "3", 61250 }, { "4", 67250 }, { "5", 77250 }, { "6", 83250 }, { "7", 175250 }, { "8", 181250 }, { "9", 187250 }, { "10", 193250 }, { "11", 199250 }, { "12", 205250 }, { "13", 211250 }, { "14", 121250 }, { "15", 127250 }, { "16", 133250 }, { "17", 139250 }, { "18", 145250 }, { "19", 151250 }, { "20", 157250 }, { "21", 163250 }, { "22", 169250 }, { "23", 217250 }, { "24", 223250 }, { "25", 229250 }, { "26", 235250 }, { "27", 241250 }, { "28", 247250 }, { "29", 253250 }, { "30", 259250 }, { "31", 265250 }, { "32", 271250 }, { "33", 277250 }, { "34", 283250 }, { "35", 289250 }, { "36", 295250 }, { "37", 301250 }, { "38", 307250 }, { "39", 313250 }, { "40", 319250 }, { "41", 325250 }, { "42", 331250 }, { "43", 337250 }, { "44", 343250 }, { "45", 349250 }, { "46", 355250 }, { "47", 361250 }, { "48", 367250 }, { "49", 373250 }, { "50", 379250 }, { "51", 385250 }, { "52", 391250 }, { "53", 397250 }, { "54", 403250 }, { "55", 409250 }, { "56", 415250 }, { "57", 421250 }, { "58", 427250 }, { "59", 433250 }, { "60", 439250 }, { "61", 445250 }, { "62", 451250 }, { "63", 457250 }, { "64", 463250 }, { "65", 469250 }, { "66", 475250 }, { "67", 481250 }, { "68", 487250 }, { "69", 493250 }, { "70", 499250 }, { "71", 505250 }, { "72", 511250 }, { "73", 517250 }, { "74", 523250 }, { "75", 529250 }, { "76", 535250 }, { "77", 541250 }, { "78", 547250 }, { "79", 553250 }, { "80", 559250 }, { "81", 565250 }, { "82", 571250 }, { "83", 577250 }, { "84", 583250 }, { "85", 589250 }, { "86", 595250 }, { "87", 601250 }, { "88", 607250 }, { "89", 613250 }, { "90", 619250 }, { "91", 625250 }, { "92", 631250 }, { "93", 637250 }, { "94", 643250 }, { "95", 91250 }, { "96", 97250 }, { "97", 103250 }, { "98", 109250 }, { "99", 115250 }, { "100", 649250 }, { "101", 655250 }, { "102", 661250 }, { "103", 667250 }, { "104", 673250 }, { "105", 679250 }, { "106", 685250 }, { "107", 691250 }, { "108", 697250 }, { "109", 703250 }, { "110", 709250 }, { "111", 715250 }, { "112", 721250 }, { "113", 727250 }, { "114", 733250 }, { "115", 739250 }, { "116", 745250 }, { "117", 751250 }, { "118", 757250 }, { "119", 763250 }, { "120", 769250 }, { "121", 775250 }, { "122", 781250 }, { "123", 787250 }, { "124", 793250 }, { "125", 799250 }, { "T7", 8250 }, { "T8", 14250 }, { "T9", 20250 }, { "T10", 26250 }, { "T11", 32250 }, { "T12", 38250 }, { "T13", 44250 }, { "T14", 50250 } }; /* US HRC */ static struct CHANLIST ntsc_hrc[] = { { "1", 72000 }, { "2", 54000 }, { "3", 60000 }, { "4", 66000 }, { "5", 78000 }, { "6", 84000 }, { "7", 174000 }, { "8", 180000 }, { "9", 186000 }, { "10", 192000 }, { "11", 198000 }, { "12", 204000 }, { "13", 210000 }, { "14", 120000 }, { "15", 126000 }, { "16", 132000 }, { "17", 138000 }, { "18", 144000 }, { "19", 150000 }, { "20", 156000 }, { "21", 162000 }, { "22", 168000 }, { "23", 216000 }, { "24", 222000 }, { "25", 228000 }, { "26", 234000 }, { "27", 240000 }, { "28", 246000 }, { "29", 252000 }, { "30", 258000 }, { "31", 264000 }, { "32", 270000 }, { "33", 276000 }, { "34", 282000 }, { "35", 288000 }, { "36", 294000 }, { "37", 300000 }, { "38", 306000 }, { "39", 312000 }, { "40", 318000 }, { "41", 324000 }, { "42", 330000 }, { "43", 336000 }, { "44", 342000 }, { "45", 348000 }, { "46", 354000 }, { "47", 360000 }, { "48", 366000 }, { "49", 372000 }, { "50", 378000 }, { "51", 384000 }, { "52", 390000 }, { "53", 396000 }, { "54", 402000 }, { "55", 408000 }, { "56", 414000 }, { "57", 420000 }, { "58", 426000 }, { "59", 432000 }, { "60", 438000 }, { "61", 444000 }, { "62", 450000 }, { "63", 456000 }, { "64", 462000 }, { "65", 468000 }, { "66", 474000 }, { "67", 480000 }, { "68", 486000 }, { "69", 492000 }, { "70", 498000 }, { "71", 504000 }, { "72", 510000 }, { "73", 516000 }, { "74", 522000 }, { "75", 528000 }, { "76", 534000 }, { "77", 540000 }, { "78", 546000 }, { "79", 552000 }, { "80", 558000 }, { "81", 564000 }, { "82", 570000 }, { "83", 576000 }, { "84", 582000 }, { "85", 588000 }, { "86", 594000 }, { "87", 600000 }, { "88", 606000 }, { "89", 612000 }, { "90", 618000 }, { "91", 624000 }, { "92", 630000 }, { "93", 636000 }, { "94", 642000 }, { "95", 90000 }, { "96", 96000 }, { "97", 102000 }, { "98", 108000 }, { "99", 114000 }, { "100", 648000 }, { "101", 654000 }, { "102", 660000 }, { "103", 666000 }, { "104", 672000 }, { "105", 678000 }, { "106", 684000 }, { "107", 690000 }, { "108", 696000 }, { "109", 702000 }, { "110", 708000 }, { "111", 714000 }, { "112", 720000 }, { "113", 726000 }, { "114", 732000 }, { "115", 738000 }, { "116", 744000 }, { "117", 750000 }, { "118", 756000 }, { "119", 762000 }, { "120", 768000 }, { "121", 774000 }, { "122", 780000 }, { "123", 786000 }, { "124", 792000 }, { "125", 798000 }, { "T7", 7000 }, { "T8", 13000 }, { "T9", 19000 }, { "T10", 25000 }, { "T11", 31000 }, { "T12", 37000 }, { "T13", 43000 }, { "T14", 49000 }, }; /* US IRC */ static struct CHANLIST ntsc_irc[] = { { "1", 73250 }, { "2", 55250 }, { "3", 61250 }, { "4", 67250 }, { "5", 79250 }, { "6", 85250 }, { "7", 175250 }, { "8", 181250 }, { "9", 187250 }, { "10", 193250 }, { "11", 199250 }, { "12", 205250 }, { "13", 211250 }, { "14", 121150 }, { "15", 127150 }, { "16", 133150 }, { "17", 139150 }, { "18", 145150 }, { "19", 151150 }, { "20", 157150 }, { "21", 163150 }, { "22", 169150 }, { "23", 217250 }, { "24", 223250 }, { "25", 229250 }, { "26", 235250 }, { "27", 241250 }, { "28", 247250 }, { "29", 253250 }, { "30", 259250 }, { "31", 265250 }, { "32", 271250 }, { "33", 277250 }, { "34", 283250 }, { "35", 289250 }, { "36", 295250 }, { "37", 301250 }, { "38", 307250 }, { "39", 313250 }, { "40", 319250 }, { "41", 325250 }, { "42", 331250 }, { "43", 337250 }, { "44", 343250 }, { "45", 349250 }, { "46", 355250 }, { "47", 361250 }, { "48", 367250 }, { "49", 373250 }, { "50", 379250 }, { "51", 385250 }, { "52", 391250 }, { "53", 397250 }, { "54", 403250 }, { "55", 409250 }, { "56", 415250 }, { "57", 421250 }, { "58", 427250 }, { "59", 433250 }, { "60", 439250 }, { "61", 445250 }, { "62", 451250 }, { "63", 457250 }, { "64", 463250 }, { "65", 469250 }, { "66", 475250 }, { "67", 481250 }, { "68", 487250 }, { "69", 493250 }, { "70", 499250 }, { "71", 505250 }, { "72", 511250 }, { "73", 517250 }, { "74", 523250 }, { "75", 529250 }, { "76", 535250 }, { "77", 541250 }, { "78", 547250 }, { "79", 553250 }, { "80", 559250 }, { "81", 565250 }, { "82", 571250 }, { "83", 577250 }, { "84", 583250 }, { "85", 589250 }, { "86", 595250 }, { "87", 601250 }, { "88", 607250 }, { "89", 613250 }, { "90", 619250 }, { "91", 625250 }, { "92", 631250 }, { "93", 637250 }, { "94", 643250 }, { "95", 91250 }, { "96", 97250 }, { "97", 103250 }, { "98", 109250 }, { "99", 115250 }, { "100", 649250 }, { "101", 655250 }, { "102", 661250 }, { "103", 667250 }, { "104", 673250 }, { "105", 679250 }, { "106", 685250 }, { "107", 691250 }, { "108", 697250 }, { "109", 703250 }, { "110", 709250 }, { "111", 715250 }, { "112", 721250 }, { "113", 727250 }, { "114", 733250 }, { "115", 739250 }, { "116", 745250 }, { "117", 751250 }, { "118", 757250 }, { "119", 763250 }, { "120", 769250 }, { "121", 775250 }, { "122", 781250 }, { "123", 787250 }, { "124", 793250 }, { "125", 799250 }, { "T7", 8250 }, { "T8", 14250 }, { "T9", 20250 }, { "T10", 26250 }, { "T11", 32250 }, { "T12", 38250 }, { "T13", 44250 }, { "T14", 50250 } }; /* --------------------------------------------------------------------- */ /* JP broadcast */ static struct CHANLIST ntsc_bcast_jp[] = { { "1", 91250 }, { "2", 97250 }, { "3", 103250 }, { "4", 171250 }, { "5", 177250 }, { "6", 183250 }, { "7", 189250 }, { "8", 193250 }, { "9", 199250 }, { "10", 205250 }, { "11", 211250 }, { "12", 217250 }, { "13", 471250 }, { "14", 477250 }, { "15", 483250 }, { "16", 489250 }, { "17", 495250 }, { "18", 501250 }, { "19", 507250 }, { "20", 513250 }, { "21", 519250 }, { "22", 525250 }, { "23", 531250 }, { "24", 537250 }, { "25", 543250 }, { "26", 549250 }, { "27", 555250 }, { "28", 561250 }, { "29", 567250 }, { "30", 573250 }, { "31", 579250 }, { "32", 585250 }, { "33", 591250 }, { "34", 597250 }, { "35", 603250 }, { "36", 609250 }, { "37", 615250 }, { "38", 621250 }, { "39", 627250 }, { "40", 633250 }, { "41", 639250 }, { "42", 645250 }, { "43", 651250 }, { "44", 657250 }, { "45", 663250 }, { "46", 669250 }, { "47", 675250 }, { "48", 681250 }, { "49", 687250 }, { "50", 693250 }, { "51", 699250 }, { "52", 705250 }, { "53", 711250 }, { "54", 717250 }, { "55", 723250 }, { "56", 729250 }, { "57", 735250 }, { "58", 741250 }, { "59", 747250 }, { "60", 753250 }, { "61", 759250 }, { "62", 765250 }, }; /* JP cable */ static struct CHANLIST ntsc_cable_jp[] = { { "13", 109250 }, { "14", 115250 }, { "15", 121250 }, { "16", 127250 }, { "17", 133250 }, { "18", 139250 }, { "19", 145250 }, { "20", 151250 }, { "21", 157250 }, { "22", 165250 }, { "23", 223250 }, { "24", 231250 }, { "25", 237250 }, { "26", 243250 }, { "27", 249250 }, { "28", 253250 }, { "29", 259250 }, { "30", 265250 }, { "31", 271250 }, { "32", 277250 }, { "33", 283250 }, { "34", 289250 }, { "35", 295250 }, { "36", 301250 }, { "37", 307250 }, { "38", 313250 }, { "39", 319250 }, { "40", 325250 }, { "41", 331250 }, { "42", 337250 }, { "43", 343250 }, { "44", 349250 }, { "45", 355250 }, { "46", 361250 }, { "47", 367250 }, { "48", 373250 }, { "49", 379250 }, { "50", 385250 }, { "51", 391250 }, { "52", 397250 }, { "53", 403250 }, { "54", 409250 }, { "55", 415250 }, { "56", 421250 }, { "57", 427250 }, { "58", 433250 }, { "59", 439250 }, { "60", 445250 }, { "61", 451250 }, { "62", 457250 }, { "63", 463250 }, }; /* --------------------------------------------------------------------- */ /* australia */ static struct CHANLIST pal_australia[] = { { "0", 46250 }, { "1", 57250 }, { "2", 64250 }, { "3", 86250 }, { "4", 95250 }, { "5", 102250 }, { "5A", 138250 }, { "6", 175250 }, { "7", 182250 }, { "8", 189250 }, { "9", 196250 }, { "10", 209250 }, { "11", 216250 }, { "28", 527250 }, { "29", 534250 }, { "30", 541250 }, { "31", 548250 }, { "32", 555250 }, { "33", 562250 }, { "34", 569250 }, { "35", 576250 }, { "36", 591250 }, { "39", 604250 }, { "40", 611250 }, { "41", 618250 }, { "42", 625250 }, { "43", 632250 }, { "44", 639250 }, { "45", 646250 }, { "46", 653250 }, { "47", 660250 }, { "48", 667250 }, { "49", 674250 }, { "50", 681250 }, { "51", 688250 }, { "52", 695250 }, { "53", 702250 }, { "54", 709250 }, { "55", 716250 }, { "56", 723250 }, { "57", 730250 }, { "58", 737250 }, { "59", 744250 }, { "60", 751250 }, { "61", 758250 }, { "62", 765250 }, { "63", 772250 }, { "64", 779250 }, { "65", 786250 }, { "66", 793250 }, { "67", 800250 }, { "68", 807250 }, { "69", 814250 }, }; static struct CHANLIST pal_australia_optus[] = { { "1", 138250 }, { "2", 147250 }, { "3", 154250 }, { "4", 161250 }, { "5", 168250 }, { "6", 175250 }, { "7", 182250 }, { "8", 189250 }, { "9", 196250 }, { "10", 209250 }, { "11", 216250 }, { "12", 224250 }, { "13", 231250 }, { "14", 238250 }, { "15", 245250 }, { "16", 252250 }, { "17", 259250 }, { "18", 266250 }, { "19", 273250 }, { "20", 280250 }, { "21", 287250 }, { "22", 294250 }, { "23", 303250 }, { "24", 310250 }, { "25", 317250 }, { "26", 324250 }, { "27", 338250 }, { "28", 345250 }, { "29", 352250 }, { "30", 359250 }, { "31", 366250 }, { "32", 373250 }, { "33", 380250 }, { "34", 387250 }, { "35", 394250 }, { "36", 401250 }, { "37", 408250 }, { "38", 415250 }, { "39", 422250 }, { "40", 429250 }, { "41", 436250 }, { "42", 443250 }, { "43", 450250 }, { "44", 457250 }, { "45", 464250 }, { "46", 471250 }, { "47", 478250 }, { "48", 485250 }, { "49", 492250 }, { "50", 499250 }, { "51", 506250 }, { "52", 513250 }, { "53", 520250 }, { "54", 527250 }, { "55", 534250 }, }; /* --------------------------------------------------------------------- */ /* europe */ /* CCIR frequencies */ #define FREQ_CCIR_I_III \ { "E2", 48250 }, \ { "E3", 55250 }, \ { "E4", 62250 }, \ \ { "S01", 69250 }, \ { "S02", 76250 }, \ { "S03", 83250 }, \ \ { "E5", 175250 }, \ { "E6", 182250 }, \ { "E7", 189250 }, \ { "E8", 196250 }, \ { "E9", 203250 }, \ { "E10", 210250 }, \ { "E11", 217250 }, \ { "E12", 224250 } #define FREQ_CCIR_SL_SH \ { "SE1", 105250 }, \ { "SE2", 112250 }, \ { "SE3", 119250 }, \ { "SE4", 126250 }, \ { "SE5", 133250 }, \ { "SE6", 140250 }, \ { "SE7", 147250 }, \ { "SE8", 154250 }, \ { "SE9", 161250 }, \ { "SE10", 168250 }, \ \ { "SE11", 231250 }, \ { "SE12", 238250 }, \ { "SE13", 245250 }, \ { "SE14", 252250 }, \ { "SE15", 259250 }, \ { "SE16", 266250 }, \ { "SE17", 273250 }, \ { "SE18", 280250 }, \ { "SE19", 287250 }, \ { "SE20", 294250 } #define FREQ_CCIR_H \ { "S21", 303250 }, \ { "S22", 311250 }, \ { "S23", 319250 }, \ { "S24", 327250 }, \ { "S25", 335250 }, \ { "S26", 343250 }, \ { "S27", 351250 }, \ { "S28", 359250 }, \ { "S29", 367250 }, \ { "S30", 375250 }, \ { "S31", 383250 }, \ { "S32", 391250 }, \ { "S33", 399250 }, \ { "S34", 407250 }, \ { "S35", 415250 }, \ { "S36", 423250 }, \ { "S37", 431250 }, \ { "S38", 439250 }, \ { "S39", 447250 }, \ { "S40", 455250 }, \ { "S41", 463250 } /* OIRT frequencies */ #define FREQ_OIRT_I_III \ { "R1", 49750 }, \ { "R2", 59250 }, \ \ { "R3", 77250 }, \ { "R4", 85250 }, \ { "R5", 93250 }, \ \ { "R6", 175250 }, \ { "R7", 183250 }, \ { "R8", 191250 }, \ { "R9", 199250 }, \ { "R10", 207250 }, \ { "R11", 215250 }, \ { "R12", 223250 } #define FREQ_OIRT_SL_SH \ { "SR1", 111250 }, \ { "SR2", 119250 }, \ { "SR3", 127250 }, \ { "SR4", 135250 }, \ { "SR5", 143250 }, \ { "SR6", 151250 }, \ { "SR7", 159250 }, \ { "SR8", 167250 }, \ \ { "SR11", 231250 }, \ { "SR12", 239250 }, \ { "SR13", 247250 }, \ { "SR14", 255250 }, \ { "SR15", 263250 }, \ { "SR16", 271250 }, \ { "SR17", 279250 }, \ { "SR18", 287250 }, \ { "SR19", 295250 } #define FREQ_UHF \ { "21", 471250 }, \ { "22", 479250 }, \ { "23", 487250 }, \ { "24", 495250 }, \ { "25", 503250 }, \ { "26", 511250 }, \ { "27", 519250 }, \ { "28", 527250 }, \ { "29", 535250 }, \ { "30", 543250 }, \ { "31", 551250 }, \ { "32", 559250 }, \ { "33", 567250 }, \ { "34", 575250 }, \ { "35", 583250 }, \ { "36", 591250 }, \ { "37", 599250 }, \ { "38", 607250 }, \ { "39", 615250 }, \ { "40", 623250 }, \ { "41", 631250 }, \ { "42", 639250 }, \ { "43", 647250 }, \ { "44", 655250 }, \ { "45", 663250 }, \ { "46", 671250 }, \ { "47", 679250 }, \ { "48", 687250 }, \ { "49", 695250 }, \ { "50", 703250 }, \ { "51", 711250 }, \ { "52", 719250 }, \ { "53", 727250 }, \ { "54", 735250 }, \ { "55", 743250 }, \ { "56", 751250 }, \ { "57", 759250 }, \ { "58", 767250 }, \ { "59", 775250 }, \ { "60", 783250 }, \ { "61", 791250 }, \ { "62", 799250 }, \ { "63", 807250 }, \ { "64", 815250 }, \ { "65", 823250 }, \ { "66", 831250 }, \ { "67", 839250 }, \ { "68", 847250 }, \ { "69", 855250 } static struct CHANLIST europe_west[] = { FREQ_CCIR_I_III, FREQ_CCIR_SL_SH, FREQ_CCIR_H, FREQ_UHF }; static struct CHANLIST europe_east[] = { FREQ_OIRT_I_III, FREQ_OIRT_SL_SH, FREQ_CCIR_I_III, FREQ_CCIR_SL_SH, FREQ_CCIR_H, FREQ_UHF }; static struct CHANLIST pal_italy[] = { { "A", 53750 }, { "B", 62250 }, { "C", 82250 }, { "D", 175250 }, { "E", 183750 }, { "F", 192250 }, { "G", 201250 }, { "H", 210250 }, { "H1", 217250 }, { "H2", 224250 }, FREQ_UHF }; static struct CHANLIST pal_ireland[] = { { "A0", 45750 }, { "A1", 48000 }, { "A2", 53750 }, { "A3", 56000 }, { "A4", 61750 }, { "A5", 64000 }, { "A6", 175250 }, { "A7", 176000 }, { "A8", 183250 }, { "A9", 184000 }, { "A10", 191250 }, { "A11", 192000 }, { "A12", 199250 }, { "A13", 200000 }, { "A14", 207250 }, { "A15", 208000 }, { "A16", 215250 }, { "A17", 216000 }, { "A18", 224000 }, { "A19", 232000 }, { "A20", 248000 }, { "A21", 256000 }, { "A22", 264000 }, { "A23", 272000 }, { "A24", 280000 }, { "A25", 288000 }, { "A26", 296000 }, { "A27", 304000 }, { "A28", 312000 }, { "A29", 320000 }, { "A30", 344000 }, { "A31", 352000 }, { "A32", 408000 }, { "A33", 416000 }, { "A34", 448000 }, { "A35", 480000 }, { "A36", 520000 }, FREQ_UHF, }; static struct CHANLIST secam_france[] = { { "K01", 47750 }, { "K02", 55750 }, { "K03", 60500 }, { "K04", 63750 }, { "K05", 176000 }, { "K06", 184000 }, { "K07", 192000 }, { "K08", 200000 }, { "K09", 208000 }, { "K10", 216000 }, { "KB", 116750 }, { "KC", 128750 }, { "KD", 140750 }, { "KE", 159750 }, { "KF", 164750 }, { "KG", 176750 }, { "KH", 188750 }, { "KI", 200750 }, { "KJ", 212750 }, { "KK", 224750 }, { "KL", 236750 }, { "KM", 248750 }, { "KN", 260750 }, { "KO", 272750 }, { "KP", 284750 }, { "KQ", 296750 }, { "H01", 303250 }, { "H02", 311250 }, { "H03", 319250 }, { "H04", 327250 }, { "H05", 335250 }, { "H06", 343250 }, { "H07", 351250 }, { "H08", 359250 }, { "H09", 367250 }, { "H10", 375250 }, { "H11", 383250 }, { "H12", 391250 }, { "H13", 399250 }, { "H14", 407250 }, { "H15", 415250 }, { "H16", 423250 }, { "H17", 431250 }, { "H18", 439250 }, { "H19", 447250 }, FREQ_UHF, }; /* --------------------------------------------------------------------- */ static struct CHANLIST pal_newzealand[] = { { "1", 45250 }, { "2", 55250 }, { "3", 62250 }, { "4", 175250 }, { "5", 182250 }, { "6", 189250 }, { "7", 196250 }, { "8", 203250 }, { "9", 210250 }, { "10", 217250 }, { "11", 224250 }, FREQ_UHF, }; /* --------------------------------------------------------------------- */ /* China broadcast */ static struct CHANLIST pal_bcast_cn[] = { { "1", 49750 }, { "2", 57750 }, { "3", 65750 }, { "4", 77250 }, { "5", 85250 }, { "6", 112250 }, { "7", 120250 }, { "8", 128250 }, { "9", 136250 }, { "10", 144250 }, { "11", 152250 }, { "12", 160250 }, { "13", 168250 }, { "14", 176250 }, { "15", 184250 }, { "16", 192250 }, { "17", 200250 }, { "18", 208250 }, { "19", 216250 }, { "20", 224250 }, { "21", 232250 }, { "22", 240250 }, { "23", 248250 }, { "24", 256250 }, { "25", 264250 }, { "26", 272250 }, { "27", 280250 }, { "28", 288250 }, { "29", 296250 }, { "30", 304250 }, { "31", 312250 }, { "32", 320250 }, { "33", 328250 }, { "34", 336250 }, { "35", 344250 }, { "36", 352250 }, { "37", 360250 }, { "38", 368250 }, { "39", 376250 }, { "40", 384250 }, { "41", 392250 }, { "42", 400250 }, { "43", 408250 }, { "44", 416250 }, { "45", 424250 }, { "46", 432250 }, { "47", 440250 }, { "48", 448250 }, { "49", 456250 }, { "50", 463250 }, { "51", 471250 }, { "52", 479250 }, { "53", 487250 }, { "54", 495250 }, { "55", 503250 }, { "56", 511250 }, { "57", 519250 }, { "58", 527250 }, { "59", 535250 }, { "60", 543250 }, { "61", 551250 }, { "62", 559250 }, { "63", 607250 }, { "64", 615250 }, { "65", 623250 }, { "66", 631250 }, { "67", 639250 }, { "68", 647250 }, { "69", 655250 }, { "70", 663250 }, { "71", 671250 }, { "72", 679250 }, { "73", 687250 }, { "74", 695250 }, { "75", 703250 }, { "76", 711250 }, { "77", 719250 }, { "78", 727250 }, { "79", 735250 }, { "80", 743250 }, { "81", 751250 }, { "82", 759250 }, { "83", 767250 }, { "84", 775250 }, { "85", 783250 }, { "86", 791250 }, { "87", 799250 }, { "88", 807250 }, { "89", 815250 }, { "90", 823250 }, { "91", 831250 }, { "92", 839250 }, { "93", 847250 }, { "94", 855250 }, }; /* --------------------------------------------------------------------- */ /* South Africa Broadcast */ static struct CHANLIST pal_bcast_za[] ={ { "4", 175250 }, { "5", 183250 }, { "6", 191250 }, { "7", 199250 }, { "8", 207250 }, { "9", 215250 }, { "10", 223250 }, { "11", 231250 }, { "12", 239250 }, { "13", 247250 }, FREQ_UHF }; /* --------------------------------------------------------------------- */ static struct CHANLIST argentina[] = { { "001", 56250 }, { "002", 62250 }, { "003", 68250 }, { "004", 78250 }, { "005", 84250 }, { "006", 176250 }, { "007", 182250 }, { "008", 188250 }, { "009", 194250 }, { "010", 200250 }, { "011", 206250 }, { "012", 212250 }, { "013", 122250 }, { "014", 128250 }, { "015", 134250 }, { "016", 140250 }, { "017", 146250 }, { "018", 152250 }, { "019", 158250 }, { "020", 164250 }, { "021", 170250 }, { "022", 218250 }, { "023", 224250 }, { "024", 230250 }, { "025", 236250 }, { "026", 242250 }, { "027", 248250 }, { "028", 254250 }, { "029", 260250 }, { "030", 266250 }, { "031", 272250 }, { "032", 278250 }, { "033", 284250 }, { "034", 290250 }, { "035", 296250 }, { "036", 302250 }, { "037", 308250 }, { "038", 314250 }, { "039", 320250 }, { "040", 326250 }, { "041", 332250 }, { "042", 338250 }, { "043", 344250 }, { "044", 350250 }, { "045", 356250 }, { "046", 362250 }, { "047", 368250 }, { "048", 374250 }, { "049", 380250 }, { "050", 386250 }, { "051", 392250 }, { "052", 398250 }, { "053", 404250 }, { "054", 410250 }, { "055", 416250 }, { "056", 422250 }, { "057", 428250 }, { "058", 434250 }, { "059", 440250 }, { "060", 446250 }, { "061", 452250 }, { "062", 458250 }, { "063", 464250 }, { "064", 470250 }, { "065", 476250 }, { "066", 482250 }, { "067", 488250 }, { "068", 494250 }, { "069", 500250 }, { "070", 506250 }, { "071", 512250 }, { "072", 518250 }, { "073", 524250 }, { "074", 530250 }, { "075", 536250 }, { "076", 542250 }, { "077", 548250 }, { "078", 554250 }, { "079", 560250 }, { "080", 566250 }, { "081", 572250 }, { "082", 578250 }, { "083", 584250 }, { "084", 590250 }, { "085", 596250 }, { "086", 602250 }, { "087", 608250 }, { "088", 614250 }, { "089", 620250 }, { "090", 626250 }, { "091", 632250 }, { "092", 638250 }, { "093", 644250 }, }; /* --------------------------------------------------------------------- */ struct CHANLISTS chanlists[] = { { "us-bcast", ntsc_bcast, CHAN_COUNT(ntsc_bcast) }, { "us-cable", ntsc_cable, CHAN_COUNT(ntsc_cable) }, { "us-cable-hrc", ntsc_hrc, CHAN_COUNT(ntsc_hrc) }, { "us-cable-irc", ntsc_irc, CHAN_COUNT(ntsc_irc) }, { "japan-bcast", ntsc_bcast_jp, CHAN_COUNT(ntsc_bcast_jp) }, { "japan-cable", ntsc_cable_jp, CHAN_COUNT(ntsc_cable_jp) }, { "europe-west", europe_west, CHAN_COUNT(europe_west) }, { "europe-east", europe_east, CHAN_COUNT(europe_east) }, { "italy", pal_italy, CHAN_COUNT(pal_italy) }, { "newzealand", pal_newzealand, CHAN_COUNT(pal_newzealand) }, { "australia", pal_australia, CHAN_COUNT(pal_australia) }, { "ireland", pal_ireland, CHAN_COUNT(pal_ireland) }, { "france", secam_france, CHAN_COUNT(secam_france) }, { "china-bcast", pal_bcast_cn, CHAN_COUNT(pal_bcast_cn) }, { "southafrica", pal_bcast_za, CHAN_COUNT(pal_bcast_za) }, { "argentina", argentina, CHAN_COUNT(argentina) }, { "australia-optus", pal_australia_optus, CHAN_COUNT(pal_australia_optus) }, { NULL, NULL, 0 } /* EOF */ }; ivtv-utils-1.4.1/utils/ivtv-tune/xawtv_parseconfig.h0000664000076400007640000000062011355717530021335 0ustar andyandyint cfg_parse_file(char *filename); void cfg_parse_option(char *section, char *tag, char *value); void cfg_parse_options(int *argc, char **argv); char** cfg_list_sections(void); char** cfg_list_entries(char *name); char* cfg_get_str(char *sec, char *ent); int cfg_get_int(char *sec, char *ent); int cfg_get_signed_int(char *sec, char *ent); float cfg_get_float(char *sec, char *ent); ivtv-utils-1.4.1/utils/ivtv-tune/cmdline.h0000664000076400007640000000526611355717530017232 0ustar andyandy/* cmdline.h */ /* File autogenerated by gengetopt version 2.14 */ #ifndef CMDLINE_H #define CMDLINE_H /* If we use autoconf. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #ifndef CMDLINE_PARSER_PACKAGE #define CMDLINE_PARSER_PACKAGE "ivtv-tune" #endif #ifndef CMDLINE_PARSER_VERSION #define CMDLINE_PARSER_VERSION "1.50" #endif struct gengetopt_args_info { char * channel_arg; /* set new channel. */ char * channel_orig; /* set new channel original value given at command line. */ char * device_arg; /* set video device node. */ char * device_orig; /* set video device node original value given at command line. */ float frequency_arg; /* set new frequency (MHz). */ char * frequency_orig; /* set new frequency (MHz) original value given at command line. */ int list_channels_flag; /* list all channels and their frequencies (default=off). */ int list_freqtable_flag; /* list all available frequency mappings (default=off). */ char * freqtable_arg; /* set frequency map to use. */ char * freqtable_orig; /* set frequency map to use original value given at command line. */ char * xawtv_arg; /* set new channel using custom map from ~/.xawtv. */ char * xawtv_orig; /* set new channel using custom map from ~/.xawtv original value given at command line. */ int help_given ; /* Whether help was given. */ int version_given ; /* Whether version was given. */ int channel_given ; /* Whether channel was given. */ int device_given ; /* Whether device was given. */ int frequency_given ; /* Whether frequency was given. */ int list_channels_given ; /* Whether list-channels was given. */ int list_freqtable_given ; /* Whether list-freqtable was given. */ int freqtable_given ; /* Whether freqtable was given. */ int xawtv_given ; /* Whether xawtv was given. */ } ; int cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info); int cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required); int cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info); void cmdline_parser_print_help(void); void cmdline_parser_print_version(void); void cmdline_parser_init (struct gengetopt_args_info *args_info); void cmdline_parser_free (struct gengetopt_args_info *args_info); int cmdline_parser_configfile (char * const filename, struct gengetopt_args_info *args_info, int override, int initialize, int check_required); int cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* CMDLINE_H */ ivtv-utils-1.4.1/utils/ivtv-tune/frequencies.h0000664000076400007640000001072211355717530020121 0ustar andyandy#ifndef FREQUENCIES_H #define FREQUENCIES_H /* * Worldwide channel/frequency list * * Nathan Laredo (laredo@broked.net) * * Frequencies are given in kHz */ #define NTSC_AUDIO_CARRIER 4500 #define PAL_AUDIO_CARRIER_I 6000 #define PAL_AUDIO_CARRIER_BGHN 5500 #define PAL_AUDIO_CARRIER_MN 4500 #define PAL_AUDIO_CARRIER_D 6500 #define SEACAM_AUDIO_DKK1L 6500 #define SEACAM_AUDIO_BG 5500 /* NICAM 728 32-kHz, 14-bit digital stereo audio is transmitted in 1ms frames containing 8 bits frame sync, 5 bits control, 11 bits additional data, and 704 bits audio data. The bit rate is reduced by transmitting only 10 bits plus parity of each 14 bit sample, the largest sample in a frame determines which 10 bits are transmitted. The parity bits for audio samples also specify the scaling factor used for that channel during that frame. The companeded audio data is interleaved to reduce the influence of dropouts and the whole frame except for sync bits is scrambled for spectrum shaping. Data is modulated using QPSK, at below following subcarrier freqs */ #define NICAM728_PAL_BGH 5850 #define NICAM728_PAL_I 6552 /* COMPREHENSIVE LIST OF FORMAT BY COUNTRY (M) NTSC used in: Antigua, Aruba, Bahamas, Barbados, Belize, Bermuda, Bolivia, Burma, Canada, Chile, Colombia, Costa Rica, Cuba, Curacao, Dominican Republic, Ecuador, El Salvador, Guam Guatemala, Honduras, Jamaica, Japan, South Korea, Mexico, Montserrat, Myanmar, Nicaragua, Panama, Peru, Philippines, Puerto Rico, St Christopher and Nevis, Samoa, Suriname, Taiwan, Trinidad/Tobago, United States, Venezuela, Virgin Islands (B) PAL used in: Albania, Algeria, Australia, Austria, Bahrain, Bangladesh, Belgium, Bosnia-Herzegovinia, Brunei Darussalam, Cambodia, Cameroon, Croatia, Cyprus, Denmark, Egypt, Ethiopia, Equatorial Guinea, Finland, Germany, Ghana, Gibraltar, Greenland, Iceland, India, Indonesia, Israel, Italy, Jordan, Kenya, Kuwait, Liberia, Libya, Luxembourg, Malaysa, Maldives, Malta, Nepal, Netherlands, New Zeland, Nigeria, Norway, Oman, Pakistan, Papua New Guinea, Portugal, Qatar, Sao Tome and Principe, Saudi Arabia, Seychelles, Sierra Leone, Singapore, Slovenia, Somali, Spain, Sri Lanka, Sudan, Swaziland, Sweden, Switzeland, Syria, Thailand, Tunisia, Turkey, Uganda, United Arab Emirates, Yemen (N) PAL used in: (Combination N = 4.5MHz audio carrier, 3.58MHz burst) Argentina (Combination N), Paraguay, Uruguay (M) PAL (525/60, 3.57MHz burst) used in: Brazil (G) PAL used in: Albania, Algeria, Austria, Bahrain, Bosnia/Herzegovinia, Cambodia, Cameroon, Croatia, Cyprus, Denmark, Egypt, Ethiopia, Equatorial Guinea, Finland, Germany, Gibraltar, Greenland, Iceland, Israel, Italy, Jordan, Kenya, Kuwait, Liberia, Libya, Luxembourg, Malaysia, Monaco, Mozambique, Netherlands, New Zealand, Norway, Oman, Pakistan, Papa New Guinea, Portugal, Qatar, Romania, Sierra Leone, Singapore, Slovenia, Somalia, Spain, Sri Lanka, Sudan, Swaziland, Sweeden, Switzerland, Syria, Thailand, Tunisia, Turkey, United Arab Emirates, Yemen, Zambia, Zimbabwe (D) PAL used in: China, North Korea, Romania, Czech Republic (H) PAL used in: Belgium (I) PAL used in: Angola, Botswana, Gambia, Guinea-Bissau, Hong Kong, Ireland, Lesotho, Malawi, Nambia, Nigeria, South Africa, Tanzania, United Kingdom, Zanzibar (B) SECAM used in: Djibouti, Greece, Iran, Iraq, Lebanon, Mali, Mauritania, Mauritus, Morocco (D) SECAM used in: Afghanistan, Armenia, Azerbaijan, Belarus, Bulgaria, Estonia, Georgia, Hungary, Zazakhstan, Lithuania, Mongolia, Moldova, Russia, Slovak Republic, Ukraine, Vietnam (G) SECAM used in: Greecem Iran, Iraq, Mali, Mauritus, Morocco, Saudi Arabia (K) SECAM used in: Armenia, Azerbaijan, Bulgaria, Estonia, Georgia, Hungary, Kazakhstan, Lithuania, Madagascar, Moldova, Poland, Russia, Slovak Republic, Ukraine, Vietnam (K1) SECAM used in: Benin, Burkina Faso, Burundi, Chad, Cape Verde, Central African Republic, Comoros, Congo, Gabon, Madagascar, Niger, Rwanda, Senegal, Togo, Zaire (L) SECAM used in: France */ /* --------------------------------------------------------------------- */ typedef struct CHANLIST { const char *name; int freq; } _chanlist; typedef struct CHANLISTS { const char *name; struct CHANLIST *list; int count; } _chanlists; #define CHAN_COUNT(x) (sizeof(x)/sizeof(struct CHANLIST)) /* --------------------------------------------------------------------- */ extern struct CHANLISTS chanlists[]; #endif ivtv-utils-1.4.1/utils/ivtv-tune/ivtv-tune.ggo0000664000076400007640000000122111355717530020070 0ustar andyandypackage "ivtv-tune" version "1.50" purpose "Channel/Frequency changer for V4L2 compatible video encoders" option "channel" c "set new channel" string typestr="CHANNEL" no option "device" d "set video device node" string typestr="DEVICE" no option "frequency" f "set new frequency (MHz)" float typestr="FREQ" no option "list-channels" l "list all channels and their frequencies" flag off option "list-freqtable" L "list all available frequency mappings" flag off option "freqtable" t "set frequency map to use" string no option "xawtv" x "set new channel using custom map from ~/.xawtv" string typestr="CHANNEL" no ivtv-utils-1.4.1/utils/ivtv-tune/ivtv-tune.10000664000076400007640000000173211355717530017463 0ustar andyandy.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36. .TH IVTV-TUNE "1" "November 2005" "ivtv-tune 1.50" "User Commands" .SH NAME ivtv-tune \- manual page for ivtv-tune 1.50 .SH SYNOPSIS .B ivtv-tune [\fIOPTIONS\fR]... .SH DESCRIPTION ivtv\-tune 1.50 .PP Channel/Frequency changer for V4L2 compatible video encoders .TP \fB\-h\fR, \fB\-\-help\fR Print help and exit .TP \fB\-V\fR, \fB\-\-version\fR Print version and exit .TP \fB\-c\fR, \fB\-\-channel\fR=\fICHANNEL\fR set new channel .TP \fB\-d\fR, \fB\-\-device\fR=\fIDEVICE\fR set video device node .TP \fB\-f\fR, \fB\-\-frequency\fR=\fIFREQ\fR set new frequency (MHz) .TP \fB\-l\fR, \fB\-\-list\-channels\fR list all channels and their frequencies (default=off) .TP \fB\-L\fR, \fB\-\-list\-freqtable\fR list all available frequency mappings (default=off) .TP \fB\-t\fR, \fB\-\-freqtable\fR=\fISTRING\fR set frequency map to use .TP \fB\-x\fR, \fB\-\-xawtv\fR=\fICHANNEL\fR set new channel using custom map from ~/.xawtv ivtv-utils-1.4.1/utils/ivtv-tune/cmdline.c0000664000076400007640000004736111355717530017227 0ustar andyandy/* File autogenerated by gengetopt version 2.14 generated with the following command: gengetopt --conf-parser -i ivtv-tune.ggo The developers of gengetopt consider the fixed text that goes in all gengetopt output files to be in the public domain: we make no copyright claims on it. */ /* If we use autoconf. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include "getopt.h" #include "cmdline.h" static void clear_given (struct gengetopt_args_info *args_info); static void clear_args (struct gengetopt_args_info *args_info); static int cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required, const char *additional_error); struct line_list { char * string_arg; struct line_list * next; }; struct line_list *cmd_line_list = 0; struct line_list *cmd_line_list_tmp = 0; static char * gengetopt_strdup (const char *s); static void clear_given (struct gengetopt_args_info *args_info) { args_info->help_given = 0 ; args_info->version_given = 0 ; args_info->channel_given = 0 ; args_info->device_given = 0 ; args_info->frequency_given = 0 ; args_info->list_channels_given = 0 ; args_info->list_freqtable_given = 0 ; args_info->freqtable_given = 0 ; args_info->xawtv_given = 0 ; } static void clear_args (struct gengetopt_args_info *args_info) { args_info->channel_arg = NULL; args_info->channel_orig = NULL; args_info->device_arg = NULL; args_info->device_orig = NULL; args_info->frequency_orig = NULL; args_info->list_channels_flag = 0; args_info->list_freqtable_flag = 0; args_info->freqtable_arg = NULL; args_info->freqtable_orig = NULL; args_info->xawtv_arg = NULL; args_info->xawtv_orig = NULL; } void cmdline_parser_print_version (void) { printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION); } void cmdline_parser_print_help (void) { cmdline_parser_print_version (); printf("\n%s\n", "Channel/Frequency changer for V4L2 compatible video encoders"); printf("\nUsage: ivtv-tune [OPTIONS]...\n\n"); printf("%s\n"," -h, --help Print help and exit"); printf("%s\n"," -V, --version Print version and exit"); printf("%s\n"," -c, --channel=CHANNEL set new channel"); printf("%s\n"," -d, --device=DEVICE set video device node"); printf("%s\n"," -f, --frequency=FREQ set new frequency (MHz)"); printf("%s\n"," -l, --list-channels list all channels and their frequencies \n (default=off)"); printf("%s\n"," -L, --list-freqtable list all available frequency mappings (default=off)"); printf("%s\n"," -t, --freqtable=STRING set frequency map to use"); printf("%s\n"," -x, --xawtv=CHANNEL set new channel using custom map from ~/.xawtv"); } void cmdline_parser_init (struct gengetopt_args_info *args_info) { clear_given (args_info); clear_args (args_info); } static void cmdline_parser_release (struct gengetopt_args_info *args_info) { if (args_info->channel_arg) { free (args_info->channel_arg); /* free previous argument */ args_info->channel_arg = 0; } if (args_info->channel_orig) { free (args_info->channel_orig); /* free previous argument */ args_info->channel_orig = 0; } if (args_info->device_arg) { free (args_info->device_arg); /* free previous argument */ args_info->device_arg = 0; } if (args_info->device_orig) { free (args_info->device_orig); /* free previous argument */ args_info->device_orig = 0; } if (args_info->frequency_orig) { free (args_info->frequency_orig); /* free previous argument */ args_info->frequency_orig = 0; } if (args_info->freqtable_arg) { free (args_info->freqtable_arg); /* free previous argument */ args_info->freqtable_arg = 0; } if (args_info->freqtable_orig) { free (args_info->freqtable_orig); /* free previous argument */ args_info->freqtable_orig = 0; } if (args_info->xawtv_arg) { free (args_info->xawtv_arg); /* free previous argument */ args_info->xawtv_arg = 0; } if (args_info->xawtv_orig) { free (args_info->xawtv_orig); /* free previous argument */ args_info->xawtv_orig = 0; } clear_given (args_info); } int cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info) { FILE *outfile; int i = 0; outfile = fopen(filename, "w"); if (!outfile) { fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename); return EXIT_FAILURE; } if (args_info->help_given) { fprintf(outfile, "%s\n", "help"); } if (args_info->version_given) { fprintf(outfile, "%s\n", "version"); } if (args_info->channel_given) { if (args_info->channel_orig) { fprintf(outfile, "%s=\"%s\"\n", "channel", args_info->channel_orig); } else { fprintf(outfile, "%s\n", "channel"); } } if (args_info->device_given) { if (args_info->device_orig) { fprintf(outfile, "%s=\"%s\"\n", "device", args_info->device_orig); } else { fprintf(outfile, "%s\n", "device"); } } if (args_info->frequency_given) { if (args_info->frequency_orig) { fprintf(outfile, "%s=\"%s\"\n", "frequency", args_info->frequency_orig); } else { fprintf(outfile, "%s\n", "frequency"); } } if (args_info->list_channels_given) { fprintf(outfile, "%s\n", "list-channels"); } if (args_info->list_freqtable_given) { fprintf(outfile, "%s\n", "list-freqtable"); } if (args_info->freqtable_given) { if (args_info->freqtable_orig) { fprintf(outfile, "%s=\"%s\"\n", "freqtable", args_info->freqtable_orig); } else { fprintf(outfile, "%s\n", "freqtable"); } } if (args_info->xawtv_given) { if (args_info->xawtv_orig) { fprintf(outfile, "%s=\"%s\"\n", "xawtv", args_info->xawtv_orig); } else { fprintf(outfile, "%s\n", "xawtv"); } } fclose (outfile); i = EXIT_SUCCESS; return i; } void cmdline_parser_free (struct gengetopt_args_info *args_info) { cmdline_parser_release (args_info); if (cmd_line_list) { /* free the list of a previous call */ while (cmd_line_list) { cmd_line_list_tmp = cmd_line_list; cmd_line_list = cmd_line_list->next; free (cmd_line_list_tmp->string_arg); free (cmd_line_list_tmp); } } } /* gengetopt_strdup() */ /* strdup.c replacement of strdup, which is not standard */ char * gengetopt_strdup (const char *s) { char *result = NULL; if (!s) return result; result = (char*)malloc(strlen(s) + 1); if (result == (char*)0) return (char*)0; strcpy(result, s); return result; } int cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info) { return cmdline_parser2 (argc, argv, args_info, 0, 1, 1); } int cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) { int result; result = cmdline_parser_internal (argc, argv, args_info, override, initialize, check_required, NULL); if (result == EXIT_FAILURE) { cmdline_parser_free (args_info); exit (EXIT_FAILURE); } return result; } int cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name) { return EXIT_SUCCESS; } int cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required, const char *additional_error) { int c; /* Character of the parsed option. */ int error = 0; struct gengetopt_args_info local_args_info; if (initialize) cmdline_parser_init (args_info); cmdline_parser_init (&local_args_info); optarg = 0; optind = 1; opterr = 1; optopt = '?'; while (1) { int option_index = 0; char *stop_char; static struct option long_options[] = { { "help", 0, NULL, 'h' }, { "version", 0, NULL, 'V' }, { "channel", 1, NULL, 'c' }, { "device", 1, NULL, 'd' }, { "frequency", 1, NULL, 'f' }, { "list-channels", 0, NULL, 'l' }, { "list-freqtable", 0, NULL, 'L' }, { "freqtable", 1, NULL, 't' }, { "xawtv", 1, NULL, 'x' }, { NULL, 0, NULL, 0 } }; stop_char = 0; c = getopt_long (argc, argv, "hVc:d:f:lLt:x:", long_options, &option_index); if (c == -1) break; /* Exit from `while (1)' loop. */ switch (c) { case 'h': /* Print help and exit. */ cmdline_parser_print_help (); cmdline_parser_free (&local_args_info); exit (EXIT_SUCCESS); case 'V': /* Print version and exit. */ cmdline_parser_print_version (); cmdline_parser_free (&local_args_info); exit (EXIT_SUCCESS); case 'c': /* set new channel. */ if (local_args_info.channel_given) { fprintf (stderr, "%s: `--channel' (`-c') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->channel_given && ! override) continue; local_args_info.channel_given = 1; args_info->channel_given = 1; if (args_info->channel_arg) free (args_info->channel_arg); /* free previous string */ args_info->channel_arg = gengetopt_strdup (optarg); if (args_info->channel_orig) free (args_info->channel_orig); /* free previous string */ args_info->channel_orig = gengetopt_strdup (optarg); break; case 'd': /* set video device node. */ if (local_args_info.device_given) { fprintf (stderr, "%s: `--device' (`-d') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->device_given && ! override) continue; local_args_info.device_given = 1; args_info->device_given = 1; if (args_info->device_arg) free (args_info->device_arg); /* free previous string */ args_info->device_arg = gengetopt_strdup (optarg); if (args_info->device_orig) free (args_info->device_orig); /* free previous string */ args_info->device_orig = gengetopt_strdup (optarg); break; case 'f': /* set new frequency (MHz). */ if (local_args_info.frequency_given) { fprintf (stderr, "%s: `--frequency' (`-f') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->frequency_given && ! override) continue; local_args_info.frequency_given = 1; args_info->frequency_given = 1; args_info->frequency_arg = (float)strtod (optarg, NULL); if (args_info->frequency_orig) free (args_info->frequency_orig); /* free previous string */ args_info->frequency_orig = gengetopt_strdup (optarg); break; case 'l': /* list all channels and their frequencies. */ if (local_args_info.list_channels_given) { fprintf (stderr, "%s: `--list-channels' (`-l') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->list_channels_given && ! override) continue; local_args_info.list_channels_given = 1; args_info->list_channels_given = 1; args_info->list_channels_flag = !(args_info->list_channels_flag); break; case 'L': /* list all available frequency mappings. */ if (local_args_info.list_freqtable_given) { fprintf (stderr, "%s: `--list-freqtable' (`-L') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->list_freqtable_given && ! override) continue; local_args_info.list_freqtable_given = 1; args_info->list_freqtable_given = 1; args_info->list_freqtable_flag = !(args_info->list_freqtable_flag); break; case 't': /* set frequency map to use. */ if (local_args_info.freqtable_given) { fprintf (stderr, "%s: `--freqtable' (`-t') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->freqtable_given && ! override) continue; local_args_info.freqtable_given = 1; args_info->freqtable_given = 1; if (args_info->freqtable_arg) free (args_info->freqtable_arg); /* free previous string */ args_info->freqtable_arg = gengetopt_strdup (optarg); if (args_info->freqtable_orig) free (args_info->freqtable_orig); /* free previous string */ args_info->freqtable_orig = gengetopt_strdup (optarg); break; case 'x': /* set new channel using custom map from ~/.xawtv. */ if (local_args_info.xawtv_given) { fprintf (stderr, "%s: `--xawtv' (`-x') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->xawtv_given && ! override) continue; local_args_info.xawtv_given = 1; args_info->xawtv_given = 1; if (args_info->xawtv_arg) free (args_info->xawtv_arg); /* free previous string */ args_info->xawtv_arg = gengetopt_strdup (optarg); if (args_info->xawtv_orig) free (args_info->xawtv_orig); /* free previous string */ args_info->xawtv_orig = gengetopt_strdup (optarg); break; case 0: /* Long option with no short option */ case '?': /* Invalid option. */ /* `getopt_long' already printed an error message. */ goto failure; default: /* bug: option not considered. */ fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : "")); exit (1); } /* switch */ } /* while */ cmdline_parser_release (&local_args_info); if ( error ) return (EXIT_FAILURE); return 0; failure: cmdline_parser_release (&local_args_info); return (EXIT_FAILURE); } #ifndef CONFIG_FILE_LINE_SIZE #define CONFIG_FILE_LINE_SIZE 2048 #endif #define ADDITIONAL_ERROR " in configuration file " #define CONFIG_FILE_LINE_BUFFER_SIZE (CONFIG_FILE_LINE_SIZE+3) /* 3 is for "--" and "=" */ char my_argv[CONFIG_FILE_LINE_BUFFER_SIZE+1]; int cmdline_parser_configfile (char * const filename, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) { FILE* file; char linebuf[CONFIG_FILE_LINE_SIZE]; int line_num = 0; int i, result, equal; char *fopt, *farg; char *str_index; size_t len, next_token; char delimiter; int my_argc = 0; char **my_argv_arg; char *additional_error; /* store the program name */ cmd_line_list_tmp = (struct line_list *) malloc (sizeof (struct line_list)); cmd_line_list_tmp->next = cmd_line_list; cmd_line_list = cmd_line_list_tmp; cmd_line_list->string_arg = gengetopt_strdup (CMDLINE_PARSER_PACKAGE); if ((file = fopen(filename, "r")) == NULL) { fprintf (stderr, "%s: Error opening configuration file '%s'\n", CMDLINE_PARSER_PACKAGE, filename); result = EXIT_FAILURE; goto conf_failure; } while ((fgets(linebuf, CONFIG_FILE_LINE_SIZE, file)) != NULL) { ++line_num; my_argv[0] = '\0'; len = strlen(linebuf); if (len > (CONFIG_FILE_LINE_BUFFER_SIZE-1)) { fprintf (stderr, "%s:%s:%d: Line too long in configuration file\n", CMDLINE_PARSER_PACKAGE, filename, line_num); result = EXIT_FAILURE; goto conf_failure; } /* find first non-whitespace character in the line */ next_token = strspn ( linebuf, " \t\r\n"); str_index = linebuf + next_token; if ( str_index[0] == '\0' || str_index[0] == '#') continue; /* empty line or comment line is skipped */ fopt = str_index; /* truncate fopt at the end of the first non-valid character */ next_token = strcspn (fopt, " \t\r\n="); if (fopt[next_token] == '\0') /* the line is over */ { farg = NULL; equal = 0; goto noarg; } /* remember if equal sign is present */ equal = (fopt[next_token] == '='); fopt[next_token++] = '\0'; /* advance pointers to the next token after the end of fopt */ next_token += strspn (fopt + next_token, " \t\r\n"); /* check for the presence of equal sign, and if so, skip it */ if ( !equal ) if ((equal = (fopt[next_token] == '='))) { next_token++; next_token += strspn (fopt + next_token, " \t\r\n"); } str_index += next_token; /* find argument */ farg = str_index; if ( farg[0] == '\"' || farg[0] == '\'' ) { /* quoted argument */ str_index = strchr (++farg, str_index[0] ); /* skip opening quote */ if (! str_index) { fprintf (stderr, "%s:%s:%d: unterminated string in configuration file\n", CMDLINE_PARSER_PACKAGE, filename, line_num); result = EXIT_FAILURE; goto conf_failure; } } else { /* read up the remaining part up to a delimiter */ next_token = strcspn (farg, " \t\r\n#\'\""); str_index += next_token; } /* truncate farg at the delimiter and store it for further check */ delimiter = *str_index, *str_index++ = '\0'; /* everything but comment is illegal at the end of line */ if (delimiter != '\0' && delimiter != '#') { str_index += strspn(str_index, " \t\r\n"); if (*str_index != '\0' && *str_index != '#') { fprintf (stderr, "%s:%s:%d: malformed string in configuration file\n", CMDLINE_PARSER_PACKAGE, filename, line_num); result = EXIT_FAILURE; goto conf_failure; } } noarg: ++my_argc; len = strlen(fopt); strcat (my_argv, len > 1 ? "--" : "-"); strcat (my_argv, fopt); if (len > 1 && ((farg &&*farg) || equal)) strcat (my_argv, "="); if (farg && *farg) strcat (my_argv, farg); cmd_line_list_tmp = (struct line_list *) malloc (sizeof (struct line_list)); cmd_line_list_tmp->next = cmd_line_list; cmd_line_list = cmd_line_list_tmp; cmd_line_list->string_arg = gengetopt_strdup(my_argv); } /* while */ ++my_argc; /* for program name */ my_argv_arg = (char **) malloc((my_argc+1) * sizeof(char *)); cmd_line_list_tmp = cmd_line_list; for (i = my_argc - 1; i >= 0; --i) { my_argv_arg[i] = cmd_line_list_tmp->string_arg; cmd_line_list_tmp = cmd_line_list_tmp->next; } my_argv_arg[my_argc] = 0; additional_error = (char *)malloc(strlen(filename) + strlen(ADDITIONAL_ERROR) + 1); strcpy (additional_error, ADDITIONAL_ERROR); strcat (additional_error, filename); result = cmdline_parser_internal (my_argc, my_argv_arg, args_info, override, initialize, check_required, additional_error); free (additional_error); free (my_argv_arg); conf_failure: if (file) fclose(file); if (result == EXIT_FAILURE) { cmdline_parser_free (args_info); exit (EXIT_FAILURE); } return result; } ivtv-utils-1.4.1/utils/ivtv-tune/xawtv_parseconfig.c0000664000076400007640000001327011355717530021335 0ustar andyandy/* * config file parser * */ #include #include #include #include "xawtv_parseconfig.h" struct CFG_ENTRIES { int ent_count; char **ent_names; char **ent_values; int **ent_seen; }; struct CFG_SECTIONS { int sec_count; char **sec_names; struct CFG_ENTRIES **sec_entries; }; /* ------------------------------------------------------------------------ */ static struct CFG_SECTIONS *c; /* ------------------------------------------------------------------------ */ #define ALLOC_SIZE 16 static struct CFG_SECTIONS* cfg_init_sections(void) { struct CFG_SECTIONS *c; c = malloc(sizeof(struct CFG_SECTIONS)); memset(c,0,sizeof(struct CFG_SECTIONS)); c->sec_names = malloc(ALLOC_SIZE*sizeof(char*)); c->sec_names[0] = NULL; c->sec_entries = malloc(ALLOC_SIZE*sizeof(struct CFG_ENTRIES*)); c->sec_entries[0] = NULL; return c; } static struct CFG_ENTRIES* cfg_init_entries(void) { struct CFG_ENTRIES *e; e = malloc(sizeof(struct CFG_ENTRIES)); memset(e,0,sizeof(struct CFG_ENTRIES)); e->ent_names = malloc(ALLOC_SIZE*sizeof(char*)); e->ent_names[0] = NULL; e->ent_values = malloc(ALLOC_SIZE*sizeof(char*)); e->ent_values[0] = NULL; e->ent_seen = malloc(ALLOC_SIZE*sizeof(int*)); e->ent_seen[0] = 0; return e; } static struct CFG_ENTRIES* cfg_find_section(struct CFG_SECTIONS *c, char *name) { struct CFG_ENTRIES* e; int i; for (i = 0; i < c->sec_count; i++) if (0 == strcasecmp(c->sec_names[i],name)) return c->sec_entries[i]; /* 404 not found => create a new one */ if ((c->sec_count % ALLOC_SIZE) == (ALLOC_SIZE-2)) { c->sec_names = realloc(c->sec_names,(c->sec_count+2+ALLOC_SIZE)*sizeof(char*)); c->sec_entries = realloc(c->sec_entries,(c->sec_count+2+ALLOC_SIZE)*sizeof(struct CFG_ENTRIES*)); } e = cfg_init_entries(); c->sec_names[c->sec_count] = strdup(name); c->sec_entries[c->sec_count] = e; c->sec_count++; c->sec_names[c->sec_count] = NULL; c->sec_entries[c->sec_count] = NULL; return e; } static void cfg_set_entry(struct CFG_ENTRIES *e, char *name, char *value) { int i; for (i = 0; i < e->ent_count; i++) if (0 == strcasecmp(e->ent_names[i],name)) break; if (i == e->ent_count) { /* 404 not found => create a new one */ if ((e->ent_count % ALLOC_SIZE) == (ALLOC_SIZE-2)) { e->ent_names = realloc(e->ent_names,(e->ent_count+2+ALLOC_SIZE)*sizeof(char*)); e->ent_values = realloc(e->ent_values,(e->ent_count+2+ALLOC_SIZE)*sizeof(char*)); e->ent_seen = realloc(e->ent_seen,(e->ent_count+2+ALLOC_SIZE)*sizeof(int*)); } e->ent_count++; e->ent_names[e->ent_count] = NULL; e->ent_values[e->ent_count] = NULL; e->ent_seen[e->ent_count] = 0; } e->ent_names[i] = strdup(name); e->ent_values[i] = strdup(value); } /* ------------------------------------------------------------------------ */ int cfg_parse_file(char *filename) { struct CFG_ENTRIES *e = NULL; char line[256],tag[64],value[192]; FILE *fp; int nr; if (NULL == c) c = cfg_init_sections(); if (NULL == (fp = fopen(filename,"r"))) return -1; nr = 0; while (NULL != fgets(line,255,fp)) { nr++; if (line[0] == '\n' || line[0] == '#' || line[0] == '%') continue; if (1 == sscanf(line,"[%99[^]]]",value)) { /* [section] */ e = cfg_find_section(c,value); } else if (2 == sscanf(line," %63[^= ] = %191[^\n]",tag,value)) { /* foo = bar */ if (NULL == e) { fprintf(stderr,"%s:%d: error: no section\n",filename,nr); } else { char *c = value + strlen(value)-1; while (c > value && (*c == ' ' || *c == '\t')) *(c--) = 0; cfg_set_entry(e,tag,value); } } else { /* Huh ? */ fprintf(stderr,"%s:%d: syntax error\n",filename,nr); } } fclose(fp); return 0; } /* ------------------------------------------------------------------------ */ void cfg_parse_option(char *section, char *tag, char *value) { struct CFG_ENTRIES *e = NULL; if (NULL == c) c = cfg_init_sections(); e = cfg_find_section(c,section); cfg_set_entry(e,tag,value); } void cfg_parse_options(int *argc, char **argv) { char section[64], tag[64]; int i,j; for (i = 1; i+1 < *argc;) { if (2 == sscanf(argv[i],"-%63[^:]:%63s",section,tag)) { cfg_parse_option(section,tag,argv[i+1]); for (j = i; j < *argc-1; j++) argv[j] = argv[j+2]; (*argc) -= 2; } else { i++; } } } /* ------------------------------------------------------------------------ */ char** cfg_list_sections() { return c->sec_names; } char** cfg_list_entries(char *name) { int i; if (NULL == c) return NULL; for (i = 0; i < c->sec_count; i++) if (0 == strcasecmp(c->sec_names[i],name)) return c->sec_entries[i]->ent_names; return NULL; } char* cfg_get_str(char *sec, char *ent) { struct CFG_ENTRIES* e = NULL; char *v = NULL; int i; for (i = 0; i < c->sec_count; i++) if (0 == strcasecmp(c->sec_names[i],sec)) e = c->sec_entries[i]; if (NULL == e) return NULL; for (i = 0; i < e->ent_count; i++) if (0 == strcasecmp(e->ent_names[i],ent)) { v = e->ent_values[i]; e->ent_seen[i]++; } return v; } int cfg_get_int(char *sec, char *ent) { char *val; val = cfg_get_str(sec,ent); if (NULL == val) return -1; return atoi(val); } int cfg_get_signed_int(char *sec, char *ent) { char *val; val = cfg_get_str(sec,ent); if (NULL == val) return 0; return atoi(val); } float cfg_get_float(char *sec, char *ent) { char *val; val = cfg_get_str(sec,ent); if (NULL == val) return -1; return atof(val); } ivtv-utils-1.4.1/utils/ivtv-tune/Makefile0000664000076400007640000000032611355717530017076 0ustar andyandyall: ivtv-tune clean: rm -f *.o ivtv-tune ivtv-tune: ivtv-tune.o frequencies.o xawtv_parseconfig.o cmdline.o cmdline.c: gengetopt --conf-parser -i ivtv-tune.ggo ivtv-tune.1: ivtv-tune help2man -N -o $@ ./$^ ivtv-utils-1.4.1/utils/ivtv-radio.c0000664000076400007640000002275511355717530015737 0ustar andyandy/* radio utility Copyright (C) 2004 Hans Verkuil Enhanced with proper options and new functionality: Copyright (C) 2004 Brian Jackson Added -c option: Copyright (C) 2004 Mark Rafn Added more options and functionality: Copyright (C) 2005 Adam Forsyth This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define RADIO_DEV "/dev/radio0" #define AUDIO_IN_DEV "/dev/video24" #define TRUE 1 #define FALSE 0 struct config { int just_tune; int passthrough; int channelchange; char prog_name[255]; struct v4l2_tuner tuner; struct v4l2_frequency freq; int fh; char radio_dev[PATH_MAX]; char audio_in[PATH_MAX]; char play_cmd[PATH_MAX + 50]; char *play_cmd_tmpl; int verbose; int div; } cfg; void print_usage(void) { fprintf(stderr, "Usage: %s \n", cfg.prog_name); fprintf(stderr, "Possible options are:\n"); fprintf(stderr, " -d Radio control device (default: %s)\n", RADIO_DEV); fprintf(stderr, " -s Scan for channels\n"); fprintf(stderr, " -a Scan for frequencies\n"); fprintf(stderr, " Use if Scan for channels is missing stuff\n"); fprintf(stderr, " If e.g. 90.9, 91.1, 91.3 all exist use this\n"); fprintf(stderr, " -f Tune to a specific frequency\n"); fprintf(stderr, " -j Just tune (don't try to play the audio)\n"); fprintf(stderr, " You'll have to play the audio yourself (see README.radio)\n"); fprintf(stderr, " -P Use passthrough mode of card\n"); fprintf(stderr, " -g Enable channel changing for passthrough mode\n"); fprintf(stderr, " -v Verbose\n"); fprintf(stderr, " -h Display this help message\n"); fprintf(stderr, " -i PCM audio capture device (default: %s)\n", AUDIO_IN_DEV); fprintf(stderr, " -c Command to play audio. This will be processed by\n"); fprintf(stderr, " the shell, after substituting %%s with the audio device.\n"); fprintf(stderr, " Default: \"%s\"\n", cfg.play_cmd_tmpl); } int scan_channels(int allfreqs) { int i; cfg.fh = open(cfg.radio_dev, O_RDONLY); if (cfg.fh == -1) { perror("radio"); fprintf(stderr, "cannot open %s\n", cfg.radio_dev); exit(1); } cfg.tuner.index = 0; if (ioctl(cfg.fh, VIDIOC_G_TUNER, &cfg.tuner) == -1) { fprintf(stderr, "ioctl: Failed to set tuner (%s)\n", strerror(errno)); exit(1); } cfg.div = (cfg.tuner.capability & V4L2_TUNER_CAP_LOW) ? 1000 : 1; int isafreq = 0; int freqindex = 0; int freqstrength; int rangehigh; int rangelow; double freqs[5][2]; double printedfreq; if (allfreqs == 1) { rangelow = cfg.tuner.rangelow; rangehigh = cfg.tuner.rangehigh; } else { rangelow = 1392 * cfg.div; rangehigh = 1728 * cfg.div; } for (i = rangelow; i < rangehigh; i += cfg.div) { cfg.freq.tuner = 0; cfg.freq.type = V4L2_TUNER_RADIO; cfg.freq.frequency = i; if (ioctl(cfg.fh, VIDIOC_S_FREQUENCY, &cfg.freq) == -1) { fprintf(stderr, "ioctl: Failed to set freq (%s)\n", strerror(errno)); exit(1); } if (ioctl(cfg.fh, VIDIOC_G_TUNER, &cfg.tuner) == -1) { fprintf(stderr, "ioctl: Failed to set tuner (%s)\n", strerror(errno)); exit(1); } //print long freq info if wanted printedfreq = cfg.freq.frequency; freqstrength = cfg.tuner.signal; if (cfg.verbose) { printf("%3.2f, %4.0f: %d \n", printedfreq / (16.0 * cfg.div), printedfreq, freqstrength); } if (cfg.tuner.signal > 16384) { isafreq++; freqindex = isafreq - 1; //if there are multiple stations in a row, this may detect the 1st and not the rest. if (isafreq < 6) { freqs[freqindex][0] = cfg.freq.frequency; freqs[freqindex][1] = cfg.tuner.signal; } } else { if (isafreq > 0) { switch(isafreq) { case 1: printedfreq = freqs[0][0]; freqstrength = freqs[0][1]; break; case 2: printedfreq = (freqs[0][0] + freqs[1][0]) / 2; freqstrength = (freqs[0][1] + freqs[1][1]) / 2; break; case 3: printedfreq = freqs[1][0]; freqstrength = freqs[1][1]; break; case 4: printedfreq = (freqs[1][0] + freqs[2][0]) / 2; freqstrength = (freqs[1][1] + freqs[2][1]) / 2; break; default: printedfreq = freqs[2][0]; freqstrength = freqs[2][1]; break; } printedfreq /= cfg.div; if (printedfreq > 1392 && printedfreq < 1728) { if ((((int)printedfreq) % 16) == 12) { printf("STATION: %3.1f FM\n", (printedfreq / 16.0) - 0.01); } else if((((int)printedfreq) % 16) == 4) { printf("STATION: %3.1f FM\n", (printedfreq / 16.0) + 0.01); } else { printf("STATION: %3.1f FM\n", (printedfreq / 16.0)); } } } isafreq = 0; } } close(cfg.fh); return 0; } static void cleanup(int signal) { printf("Cleaning up\n"); if (cfg.passthrough) { cfg.passthrough = VIDEO_SOURCE_MEMORY; ioctl(cfg.fh, VIDEO_SELECT_SOURCE, (void *)(unsigned long)cfg.passthrough); } close(cfg.fh); exit(0); } int main(int argc, char **argv) { int opt; strcpy(cfg.prog_name, argv[0]); strcpy(cfg.radio_dev, RADIO_DEV); strcpy(cfg.audio_in, AUDIO_IN_DEV); cfg.play_cmd_tmpl = "aplay -f dat < %s"; cfg.just_tune = FALSE; cfg.passthrough = VIDEO_SOURCE_MEMORY; cfg.verbose = 0; if (argc < 2) { print_usage(); exit(1); } while ((opt = getopt(argc, argv, "vghjPsad:f:i:c:")) != -1) { switch (opt) { case 'j': cfg.just_tune = TRUE; break; case 'P': printf("Setting passthrough mode\n"); cfg.passthrough = VIDEO_SOURCE_DEMUX; break; case 'f': cfg.freq.frequency = (__u32)(atof(optarg) * 16000 + .5); break; case 'd': strcpy(cfg.radio_dev, optarg); break; case 'i': strcpy(cfg.audio_in, optarg); break; case 'c': cfg.play_cmd_tmpl = optarg; break; case 'g': cfg.channelchange = TRUE; break; case 's': scan_channels(0); exit(0); case 'a': scan_channels(1); exit(0); case 'v': cfg.verbose = 1; break; case 'h': print_usage(); exit(0); default: fprintf(stderr, "Unknown option\n"); print_usage(); exit(1); } } cfg.fh = open(cfg.radio_dev, O_RDWR); if (cfg.fh == -1) { perror("radio"); fprintf(stderr, "cannot open %s\n", cfg.radio_dev); exit(1); } ioctl(cfg.fh, VIDIOC_G_TUNER, &cfg.tuner); cfg.div = (cfg.tuner.capability & V4L2_TUNER_CAP_LOW) ? 1000 : 1; if (cfg.div == 1) cfg.freq.frequency /= 1000; cfg.freq.tuner = 0; cfg.freq.type = V4L2_TUNER_RADIO; if (cfg.freq.frequency) { printf("set to freq %3.2f\n", cfg.freq.frequency / (16.0 * cfg.div)); ioctl(cfg.fh, VIDIOC_S_FREQUENCY, &cfg.freq); if (cfg.verbose) { printf("signal strength: %d\n", cfg.tuner.signal); } } if (cfg.passthrough == VIDEO_SOURCE_DEMUX) { if (ioctl(cfg.fh, VIDEO_SELECT_SOURCE, (void *)(unsigned long)cfg.passthrough) < 0) { fprintf(stderr, "passthrough ioctl failed\n"); exit(1); } cfg.just_tune = TRUE; } signal(SIGPIPE, cleanup); signal(SIGHUP, cleanup); signal(SIGTERM, cleanup); signal(SIGUSR1, cleanup); signal(SIGINT, cleanup); /* if they want us to just tune, do that and wait, otherwise we play the output with aplay */ if (cfg.just_tune) { //allow in-program channel changing for passthru mode / just tune mode if(cfg.channelchange) { char newfreqs[8]; while (1) { printf("Enter the frequency to change to: "); scanf("%s",newfreqs); cfg.freq.tuner = 0; cfg.freq.type = V4L2_TUNER_RADIO; cfg.freq.frequency = 16 * cfg.div * atof(newfreqs); printf("set to freq %3.2f\n", cfg.freq.frequency / (16.0 * cfg.div)); ioctl(cfg.fh, VIDIOC_S_FREQUENCY, &cfg.freq); } } else { pause(); } } else { struct v4l2_capability radio_cap; struct v4l2_capability audio_cap; int fd; ioctl(cfg.fh, VIDIOC_QUERYCAP, &radio_cap); fd = open(cfg.audio_in, O_RDONLY); audio_cap.bus_info[0] = 0; if (fd != -1) { ioctl(fd, VIDIOC_QUERYCAP, &audio_cap); close(fd); } if (strcmp((char *)radio_cap.bus_info, (char *)audio_cap.bus_info)) { fprintf(stderr, "%s belongs to a different ivtv driver then %s.\n", cfg.audio_in, cfg.radio_dev); fprintf(stderr, "Run ivtv-detect to discover the correct radio/PCM out combination.\n"); exit(1); } snprintf(cfg.play_cmd, sizeof(cfg.play_cmd), cfg.play_cmd_tmpl, cfg.audio_in); printf("Running: %s\n", cfg.play_cmd); if ((system(cfg.play_cmd)) == -1) { fprintf(stderr, "Failed to play audio with aplay\n"); fprintf(stderr, "Make sure you have it installed\n"); exit(1); } } cleanup(0); return 0; } ivtv-utils-1.4.1/utils/perl/0000775000076400007640000000000011355717714014442 5ustar andyandyivtv-utils-1.4.1/utils/perl/README.ptune0000664000076400007640000000365511355717530016461 0ustar andyandyptune.pl ============================================ This script provides a means for a user to change the tuner frequency. It is dependant on Marc Lehmann's Video-Capture-V4l package, ptune-ui.pl is a graphical interface, which also relies on Tk.pm. It also depends on Video::ivtv, Getopt::Long and the updated Video::Frequencies packages. 1) Load the ivtv.o module (and any supporting modules) 2) Run the ptune script: $ ptune.pl 11 Ch.11: 199250 3118 3) cat /dev/video0 > filename.mpg or use record-v4l2.pl to record video from your tuned in tv station. NOTES: ptune.pl now supports specifying the frequency table to use, etc. Run ptune.pl without any arguments or with -h/--help to get usage info. ptune.pl now supports reading profiles from the ~/.ivtvrc config file. This will allow those people who have to make a custom channel mapping to specify it as a profile section and then call ptune.pl specifying the "channel" as the --profile argument to tune in the correct frequency. Ex: Custom channel mapping for channel 23, frequency = 1234567. in ~/.ivtvrc after the [defaults] section is done, add: [23] Frequency=1234567 You can now do: ptune.pl --profile 23 and have it tune to frequency 1234567 for you. Note: The frequency above is totally fake! You can now alternatively use the new custom freqtable support to do the same: ptune.pl --freqtable custom 23 would tune in the frequency specified by profile 23 in your config file. If you want to get a listing of available channels for the frequency table you are using, do: ptune.pl --list-channels Make sure you specify the --freqtable option before --list-channels otherwise it will use the default in the program or from your ~/.ivtvrc config file. TODO: * Add options to ptune.pl to switch to the S-Video and Composite inputs. If you want that now, use record-v4l2.pl and specify the --no-record option to just mimic ptune.pl. It will let you set all the available options. ivtv-utils-1.4.1/utils/perl/record-v4l2.pl0000775000076400007640000016037611355717530017056 0ustar andyandy#!/usr/bin/perl # record-v4l2.pl created by James A. Pattie 04/10/2003 # Copyright 2003-2004 # Purpose: to record from the specified channel for the specified amount # of time to the video OutputDirectory under the channel-start time name as video.mpg. # # You can always get the latest version of this script at # http://www.pcxperience.org/ # # 20030425 - 1.4 - Added devfs support based upon patch submitted by # Jonathan Kolb # 20030426 - 1.5 - Imported the ptune.pl functionality # 20030426 - 1.6 - moved -F -> -L, -F now lets you specify the frequency to tune to. # 20030427 - 1.7 - renamed to record_ivtv.pl per Kevin's request. Added -R option. # 20030430 - 1.8 - fixing some comparisons that needed to be strings, etc. # 20030504 - 1.9 - Migrating to Video::ivtv for video resolution support. # 20030505 - 1.10- Replaced open w/ sysopen but it doesn't make a difference. # Starting to replace the Standard code w/ Video::ivtv methods. # Added the version numbers that I require to the use statements. # 20030507 - 1.11- Migrated to using get/setFrequency from Video::ivtv 0.03. # 20030510 - 1.12- Migrated to using get/setInput from Video::ivtv 0.04. Moved to using # the exported method names rather than Video::ivtv::method(). # Converted to using enumerateStandard(). # Fixed the condition where switching Video Standards will most likely # not get the correct channel and so would switch back with channel = 0 # which is invalid. In this case I store the previous frequency, do the # channel change but signal to restore the previous frequency on cleanup. # Converted to using enumerateInput(). # 20030512 - 1.13- Added initial support for setting the bitrate/bitrate_peak values. # 20030513 - 1.14- Tweaked the bitrate values to be closer to real DVD bitrates. # Added support for the .ivtvrc config file and User Profiles. # 20030516 - 1.15- Updated to the OO interface that Video::ivtv 0.06 now requires. # Cleaned up a lot of the global variables into a settings hash. # Made the -S command add any config items you specified on the command line # that were not in the Profile being updated. This way you can add new items. # Made the config file work from a mapping hash so that we can easily add/remove # config items in the future. # 20030518 - 1.16- Fixed a Frequency bug that happened when changing Video Standards and the # Frequency came from a user specified Profile. # 20030519 - 1.17- Adding the rest of the Codec related options to the config file / defaults. # Switched to using Getopt::Long. You can specify all config file options at # least by a --long version and still by the original -X command option. # Cleaned up the option parsing code to take advantage of the mappings hash. # 20030520 - 1.18- Fixing the handling of the Profile command line option. # 20030524 - 1.19- Cleaned up the output for -L/--list-freqtable. Changed --list -> --list-freqtable. # Added support to detect the v4l2 driver in use and disable the ivtv "enhancements" # if driver != "ivtv". # Renamed to record-v4l2.pl to reflect the ability of this program to record from any # v4l2 device but with special support for the ivtv driver. # 20030524 - 1.20- Improving the Ctrl-C handling (cleanup before dying). It may take a second or two # before the program exits, but it should exit after resetting anything it changed, unless # you had specified not to reset the card. # Allow layering of profiles by calling -P/--profile multiple times. Each profile will # be layered over the last. You will not be able to create/update a profile if you # specify more than one though. # Fixed a bug that would cause a parameter from the profile to be set n times, where n was # the number of characters in the mapping string that consisted of the single letter | and # the long command option name. Ex: Channel has 'c|channel' so the Channel value was being # set 9 times instead of just the first time if it was in the profile. # 20030525 - 1.21- Fixed devfsd detection code as it was overriding what came from the config file. # Adding --no-record option so that we can start to implement the replacement functionality for # ptune.pl (ie. Set all values and then exit, do not reset the card and do not capture) # 20030607 - 1.22- Adding --directory-format and --date-format options so that the user can specify the # naming convention to use when specifying the directory the output file should be put in. # Tweaked some of the defaults. # Create the config file if it doesn't exist, regardless of the --save flag being specified. # Added method error() to output an error condition that doesn't warrant the whole usage and # converted all relevant usage() calls to error() calls. # Added option --debug to dynamically on the fly enable debug output. # 20030609 - 1.23- Added option --list-channels to display the currently selected frequency tables contents. # Changed the default output directory to '.'. # Moved $debug -> $settings{Debug} so it can be stored in the config file. This allows you to # turn debugging on for only certain profiles, etc. # Restructured some of the validity tests to only happen as long as we are recording since they # do not need to be validated when we are not recording. Mainly to do with the output stuff. # 20030610 - 1.24- Moved the tunerNum variable into the config file: TunerNum # Added --tuner-num option to dynamically set it. # 20030614 - 1.25- I now require Video::ivtv 0.09 to make sure everyone is using the version that fixes the known # reported segfault issues. # Added freqtable "custom" support so that people using the new feature in ptune-ui.pl and have # set their default frequency table to be "custom" will just work when they specify channel X, etc. # I'm now sorting the command line input since otherwise I can't guarantee the order options get # processed in, but even that is wrong. I need to use Tie::IxHash, but that isn't standard. # 20030626 - 1.26- Updated to cover the audio -> audio_bitmask changes that Video::ivtv 0.11 implemented to cover # the ivtv_ioctl_codec structure changes. # Implemented config file versioning so that I know when the Audio entry needs to be updated in case it # comes back in a future version of the ivtv_ioctl_codec structure. # 20030628 - 1.27- Adding --list-inputs and --list-standards to display the available inputs and video standards. # 20030713 - 1.28- Added code to make sure the codec properties are proper when switching standard to PAL/SECAM. # Added config options SetMSPMatrix, MSPInput, MSPOutput, MSPSleep to allow the user to specify if they # want the msp matrix updated any time the Video Standard is changed and to specify what they want programmed. # Bumping the config file version to 2 to account for the new options. # 20030715 - 1.29- Adding the missing msp matrix reset code in the reset section. # Adding codec checks to make sure that they are right for NTSC. # Made it legal to specify the channel by itself without -c/--channel. # 20030822 - 1.30- Adding the missing codec value BitrateMode # 20030927 - 1.31- Adding support to export the settings used as a shell or perl snippet for inclusion # by scripts working with the recorded video files. # Changing the default value of StreamType to 14 since that is near DVD quality. # 20040306 - 1.32- Creating the parent directory if it doesn't exist. # Making sure to update the InputName if the config specified a number so that input switching works 100%. # Command line arguments now take precedence over Profile values, should have been this way always. :( # 20040613 - 1.33- Removing the MSPMatrix related options and code. # Adding a check for the 0.1.10 driver and not using the GOP_END ioctl if it is not that version. # Brought it upto speed in regards to the 0.2.00rc1g driver - all known issues are now fixed. # Added code to determine the version of the ivtv driver being used (0.1.10, 0.2.0, etc.) and # output it in the video.settings file so we know what driver the capture was done with. use strict; use Getopt::Long qw(:config no_ignore_case bundling); use Fcntl; use Video::Frequencies 0.03; use Video::ivtv 0.13; use Config::IniFiles; my $version="1.33"; my $cfgVersion = "3"; my $cfgVersionStr = "_configVersion_"; # hopefully unique [defaults] value to let me know what version the config file is. my $ivtvVersion = 0; # used to store the detected version of the driver. Needed for the CaptureLastGOP feature. my @capabilities = (); # The cards capabilities my %settings = ( Channel => 4, # default to the ivtv default channel RecordDuration => 3595, # default to 59 minutes 55 seconds (in seconds) - This lets 2 back to back cron jobs work! InputNum => 0, # TV-Tuner 1 InputName => "Tuner 1", OutputDirectory => ".", VideoDevice => "/dev/video0", VideoWidth => "720", # 720x480-fullscreen NTSC VideoHeight => "480", VideoStandard => "NTSC", # NTSC, PAL or SECAM VideoType => "mpeg", # mpeg, yuv BitrateMode => 0, # 0 = VBR, 1 = CBR Bitrate => "6500000", PeakBitrate => "8000000", # peak bitrate Aspect => 2, AudioBitmask => 0x00e9, BFrames => 3, DNRMode => 0, DNRSpatial => 0, DNRTemporal => 0, DNRType => 0, Framerate => 0, FramesPerGOP => 15, GOPClosure => 1, Pulldown => 0, StreamType => 14, # 0 = PS, 1 = TS, 2 = MPEG1, 3 = PES_AV, 5 = PES_V, 7 = PES_A, 10 = DVD, 11 = VCD, 12 = SVCD, 13 = DVD-Special 1, 14 = DVD-Special 2 OutputFileName => "video.mpg", FrequencyTable => "ntsc-cable", # default to NTSC_CABLE mapping. Frequency => "", # user specified frequency. ResetCardSettings => 1, ConfigFileName => "$ENV{HOME}/.ivtvrc", UpdateConfigFile => 0, UseConfigFile => 0, UsingIvtvDriver => 1, # default to being able to use the ivtv "enhancements". DontRecord => 0, # default to always recording data. DirectoryFormatString => "%I-%c-%d", # format string used to define the sub directory under OutputDirectory DateTimeFormatString => "+%Y%m%d-%H%M", # format string used to represent the date/time if the user wants it in their DirectoryFormatString # define the Codec related min/max values minBitrate => 1, maxBitrate => 14500000, minPeakBitrate => 1150, maxPeakBitrate => 16000000, # output settings file settings OutputSettings => 1, # bool 0 or 1 OutputSettingsName => "video.settings", OutputSettingsType => "shell", # shell or perl # other settings CaptureLastGOP => 1, # default to trying to Capture the Last GOP of the encoder stream. Debug => 0, TunerNum => 1, v4l2DriverVersion => 0, v4l2DriverVersionStr => "", v4l2Driver => "", ); my $result=""; my @profileNames=(); # list of user defined sections to work with in the config file. my %profileOverloads = (); # hash of entries the Profiles overloaded so InputName <-> InputNum works properly. my %configIni; # config hash we tie to for Config::IniFiles. my $ivtvObj = Video::ivtv->new(); # map the Settings/Config file parameter to the command line variable that specifies it. my %mappings = ( "Channel" => "c|channel", "RecordDuration" => "t|duration", "InputNum" => "i|inputnum", "InputName" => "I|inputname", "OutputDirectory" => "D|directory", "VideoDevice" => "d|input", "VideoWidth" => "W|width", "VideoHeight" => "H|height", "VideoStandard" => "s|standard", "VideoType" => "T|type", "BitrateMode" => "bitrate-mode", "Bitrate" => "b|bitrate", "PeakBitrate" => "B|peakbitrate", "Aspect" => "aspect", "AudioBitmask" => "audio-bitmask", "BFrames" => "bframes", "DNRMode" => "dnrmode", "DNRSpatial" => "dnrspatial", "DNRTemporal" => "dnrtemporal", "DNRType" => "dnrtype", "Framerate" => "framerate", "FramesPerGOP" => "framespergop", "GOPClosure" => "gopclosure", "Pulldown" => "pulldown", "StreamType" => "streamtype", "OutputFileName" => "o|output", "FrequencyTable" => "f|freqtable", "Frequency" => "F|frequency", "ResetCardSettings" => "R|noreset", "DirectoryFormatString" => "directory-format", "DateTimeFormatString" => "date-format", "Debug" => "debug", "TunerNum" => "tuner-num", "OutputSettings" => "output-settings", "OutputSettingsName" => "output-settings-name", "OutputSettingsType" => "output-settings-type", "CaptureLastGOP" => "capture-last-gop", ); my %codecMappings = ( "Aspect" => "aspect", "AudioBitmask" => "audio_bitmask", "BFrames" => "bframes", "BitrateMode" => "bitrate_mode", "Bitrate" => "bitrate", "PeakBitrate" => "bitrate_peak", "DNRMode" => "dnr_mode", "DNRSpatial" => "dnr_spatial", "DNRTemporal" => "dnr_temporal", "DNRType" => "dnr_type", "Framerate" => "framerate", "FramesPerGOP" => "framespergop", "GOPClosure" => "gop_closure", "Pulldown" => "pulldown", "StreamType" => "stream_type", ); # check for devfs support if ( -e "/dev/.devfsd" ) { $settings{VideoDevice} = "/dev/v4l/video0"; } # check for the config file if (-f $settings{ConfigFileName}) { $settings{UseConfigFile} = 1; # tie to it. tie %configIni, 'Config::IniFiles', (-file => $settings{ConfigFileName}) or die "Error: Opening config file '$settings{ConfigFileName}' failed! $!\n"; my $profile = "defaults"; if (exists $configIni{$profile}) { my $saveFile = 0; # check version of the config file. if (!exists $configIni{$profile}{$cfgVersionStr}) { print "Updating config file to version 1...\n"; # first version config file! Update the Audio -> AudioBitmask entries. $configIni{$profile}{$cfgVersionStr} = 1; # find all entries that have Audio and move to AudioBitmask. foreach my $p (keys %configIni) { if (exists $configIni{$p}{Audio}) { $configIni{$p}{AudioBitmask} = $configIni{$p}{Audio}; delete $configIni{$p}{Audio}; } } $saveFile = 1; # signal we need to save the config changes. } if ($configIni{$profile}{$cfgVersionStr} != $cfgVersion) { # we need to upgrade if ($configIni{$profile}{$cfgVersionStr} == 1) { print "Updating config file to version 2...\n"; # add the MSP Matrix related options. $configIni{$profile}{SetMSPMatrix} = $settings{SetMSPMatrix}; $configIni{$profile}{MSPInput} = $settings{MSPInput}; $configIni{$profile}{MSPOutput} = $settings{MSPOutput}; $configIni{$profile}{MSPSleep} = $settings{MSPSleep}; $configIni{$profile}{$cfgVersionStr} = 2; $saveFile = 1; } if ($configIni{$profile}{$cfgVersionStr} == 2) { print "Updating config file to version 3...\n"; # remove the MSP Matrix related options from all profiles. foreach my $p (keys %configIni) { foreach my $k (qw(SetMSPMatrix MSPInput MSPOutput MSPSleep)) { if (exists $configIni{$p}{$k}) { delete $configIni{$p}{$k}; } } } $configIni{$profile}{CaptureLastGOP} = 1; $configIni{$profile}{$cfgVersionStr} = 3; $saveFile = 1; } } if ($saveFile) { # now save the updated config file before we continue. tied(%configIni)->RewriteConfig or die "Error: Writing config file '$settings{ConfigFileName}' failed! $!\n"; } # update the defaults stored. foreach my $arg (keys %mappings) { if (exists $configIni{$profile}{$arg}) { $settings{$arg} = $configIni{$profile}{$arg}; #print "settings{$arg} = '" . $settings{$arg} . "'\n"; } } } else { print "Warning: config file '$settings{ConfigFileName}' exists but does not have the\n[$profile] section! Use -S to create it without specifying -P.\n\n"; } } else # create the config file { print "Auto Creating config file $settings{ConfigFileName}...\n"; my $profile = "defaults"; # we have to create the config file and tie to it. tie %configIni, 'Config::IniFiles', () or die "Error: Initializing config file '$settings{ConfigFileName}' failed! $!\n"; # now set the name to work with. tied(%configIni)->SetFileName($settings{ConfigFileName}) or die "Error: Setting config file to '$settings{ConfigFileName}' failed! $!\n"; $configIni{$profile} = {}; # make sure the section exists. foreach my $arg (keys %mappings) { $configIni{$profile}{$arg} = $settings{$arg}; print "configIni{$profile}{$arg} = '" . $settings{$arg} . "'\n" if $settings{Debug}; } # set the config file version $configIni{$profile}{$cfgVersionStr} = $cfgVersion; # write the config file out. tied(%configIni)->RewriteConfig or die "Error: Writing config file '$settings{ConfigFileName}' failed! $!\n"; } # build up the "custom" frequency table my %customMap = (); foreach my $profileName (keys %configIni) { next if $profileName =~ /^(defaults)$/; if (exists $configIni{$profileName}{Frequency}) { $customMap{$profileName} = $configIni{$profileName}{Frequency}; } } $CHANLIST{custom} = \%customMap; # enumerations my @standards; my %name2std; my @inputs; my %name2input; my @codecInfo; # stores the Codec Info my @newCodecInfo; # the version we mess with. # Current settings (Input, Channel, Standard) my $curinput; my $curinputName; my $std; my $curstd = "???"; my $curStandard = 0; # numeric representation. my $curChannel = 0; my $curFrequency = 0; my $tuner; my $settingsFH; # File Handle for output settings. my $err; my $v4l2input; my $tmpDirectoryStr = formatDirectoryString(); my $versionStr = "record-v4l2.pl $version for use with http://ivtv.sf.net/"; my $usageStr = <<"END_OF_USAGE"; $versionStr Usage: record-v4l2.pl [--channel CHANNEL] [--duration TIME] [--directory DIRECTORY] [--output OUTPUT] [--directory-format FORMAT] [--date-format FORMAT] [--input VIDEO_DEV][--width WIDTH --height HEIGHT] [--standard STANDARD] [--type TYPE] [--inputnum INPUT#] [--inputname INPUT NAME] [--freqtable FREQENCY MAP] [--frequency FREQUENCY] [--bitrate-mode MODE] [--bitrate BITRATE] [--peakbitrate PEAK_BITRATE] [--profile PROFILE] [--list-freqtable] [--list-channels] [--no-record] [--noreset] [--save] [--help] [--version] [--aspect ASPECT] [--audio-bitmask AUDIO-BITMASK] [--bframes BFRAMES] [--dnrmode DNRMODE] [--dnrspatial DNRSPATIAL] [--dnrtemporal DNRTEMPORAL] [--dnrtype DNRTYPE] [--framerate FRAMERATE] [--framespergop FRAMESPERGOP] [--gopclosure GOPCLOSURE] [--capture-last-gop GOP_END] [--pulldown PULLDOWN] [--streamtype STREAMTYPE] [--debug] [--tuner-num TUNERNUM] [--output-settings BOOL] [--output-settings-name FNAME] [--output-settings-type TYPE] [--list-inputs] [--list-standards] [CHANNEL] -c/--channel CHANNEL: channel number to switch to NOTE: You can also specify the channel by itself. Ex. record-v4l2.pl 73 would change to channel 73 using the default settings or the settings from your ~/.ivtvrc config file. -t/--duration TIME: number of seconds to record -D/--directory DIRECTORY: Base directory to record into --directory-format FORMAT: format string that specifies the sub-directory to create under the base directory that the output file will be created in. This can be empty to indicate no sub-directory should be created. Available tokens are: %d - date formatted by --date-format %I - input name recorded from Any white space in the name is converted to underscores (_). Ex. 'Tuner 0' => 'Tuner_0' %c - channel or "freq-#" frequency --date-format FORMAT: format string that specifies the date format string to generate and substitute for %d in the --directory-format string. Available tokens: see the date commands man page. The string must start with a + (plus). -o/--output OUTPUT: name of file to create -d/--input VIDEO_DEV: video device to capture from -W/--width WIDTH: width of screen (720 for NTSC fullscreen) -H/--height HEIGHT: height of screen (480 for NTSC fullscreen) -s/--standard STANDARD: NTSC, PAL or SECAM - video standard to record in -T/--type TYPE: mpeg or yuv output -i/--inputnum INPUT#: The index number of the input you want to use (0 -> n-1) -I/--inputname INPUT NAME: The name of the input you want to use. -f/--freqtable FREQUENCY MAP: Specify the frequency mapping to use. -F/--frequency FREQUENCY: Specify the frequency to tune to. ex. 517250 = NTSC Cable 73 (SCiFi) --tuner-num TUNERNUM: Specify the tuner to use. -L/--list-freqtable: list all available frequency mappings that Video::Frequencies knows --list-channels: lists all channels and their frequencies for the specified frequency table being used. --list-inputs: lists all inputs the v4l2 driver reports. --list-standards: lists all Video Standards the v4l2 driver supports. -R/--noreset: Do not Reset anything that was changed (standard, channel, resolution, etc.) --no-record: Do not create any directories, capture data or reset the card back to original settings. This is the ptune.pl mode. -h/--help: display this help -v/--version: display the version of this program --debug: turns on debug output --output-settings BOOL: Turns on or off the creation of the settings file that contains perl or shell variables that represent the settings used to record the video file. This feature is ignored if --no-record specified. --output-settings-name FNAME: The name of the file to write the settings to. It must end in .settings. --output-settings-type TYPE: Either 'shell' or 'perl'. If 'shell', then all variables output are prefixed with REC_ and are upper cased. Ex: StreamType => REC_STREAMTYPE="14" If 'perl', then all variables output are created in the %settings hash. Ex: StreamType => $settings{StreamType} = "14"; Codec related options: --bitrate-mode MODE: 0 = VBR, 1 = CBR -b/--bitrate BITRATE: Specify the Bitrate to capture at in Mbps -B/--peakbitrate PEAK_BITRATE: Specify the Peak Bitrate to capture at in Mbps --aspect ASPECT: Specify the aspect ratio --audio-bitmask AUDIO-BITMASK: Specify the audio bitmask value --bframes BFRAMES: Specify the number of B frames value --dnrmode DNRMODE: Specify the dnr_mode value --dnrspatial DNRSPATIAL: Specify the dnr_spatial value --dnrtemporal DNRTEMPORAL: Specify the dnr_temporal value --dnrtype DNRTYPE: Specify the dnr_type value --framerate FRAMERATE: Specify the framerate value. 0 = 30fps, 1 = 25fps --framespergop FRAMESPERGOP: Specify the GOP size --gopclosure GOPCLOSURE: Specify if you want open/closed GOP's. --capture-last-gop GOP_END: Specify if you want the encoder stream to try and capture the last GOP, thus generating a 100% valid mpeg2 file. 1 = yes (default), 0 = no. --pulldown PULLDOWN: 1 = Inverse telecine on, 0 = off --streamtype STREAMTYPE: Specify the stream_type value Valid Values are: 0 - PS 1 - TS 2 - MPEG1 3 - PES_AV 5 - PES_V 7 - PES_A 10 - DVD 11 - VCD 12 - SVCD 13 - DVD-Special 1 14 - DVD-Special 2 Config file related options: -P/--profile PROFILE: Override defaults and command line values with the config entries in the section labeled [PROFILE] from the config file $settings{ConfigFileName}. Examples: -P NTSC-DVD, -P PAL-DVD, --profile MY-SETTINGS You can specify this option multiple times and each successive profile will overlay the defaults and any previous profiles. You will not be able to create/update a profile if you do specify multiple profiles. -S/--save: save the current values as the defaults in $settings{ConfigFileName}. If -P/--profile PROFILE is specified, then those values that exist in the specified profile will be updated. If the profile doesn't exist, then it will be created, but will have all possible config items defined in it. It will be your responsibility to hand check the config file and remove any config items you do not want set for that profile. Any options specified on the command line will override options defined in the config file. Notes: If you specify both -i/--inputnum and -I/--inputname then -i/--inputnum will take precedence. If you specify both -c/--channel and -F/--frequency then -F/--frequency will take precedence. If you use a Profile, it has the ability to override all command line arguments, so check your Profile first if things seem to be ignored. Defaults: --duration $settings{RecordDuration} --input $settings{VideoDevice} --width $settings{VideoWidth} --height $settings{VideoHeight} --standard $settings{VideoStandard} --type $settings{VideoType} --directory $settings{OutputDirectory} --output $settings{OutputFileName} --directory-format "$settings{DirectoryFormatString}" --date-format "$settings{DateTimeFormatString}" --inputnum $settings{InputNum} --inputname '$settings{InputName}' --freqtable $settings{FrequencyTable} --capture-last-gop $settings{CaptureLastGOP} --bitrate $settings{Bitrate} --peakbitrate $settings{PeakBitrate} --aspect $settings{Aspect} --audio-bitmask $settings{AudioBitmask} --bframes $settings{BFrames} --dnrmode $settings{DNRMode} --dnrspatial $settings{DNRSpatial} --dnrtemporal $settings{DNRTemporal} --dnrtype $settings{DNRType} --framerate $settings{Framerate} --framespergop $settings{FramesPerGOP} --gopclosure $settings{GOPClosure} --pulldown $settings{Pulldown} --streamtype $settings{StreamType} --tuner-num $settings{TunerNum} --output-settings $settings{OutputSettings} --output-settings-name $settings{OutputSettingsName} --output-settings-type $settings{OutputSettingsType} config file = '$settings{ConfigFileName}' If Channel = $settings{Channel}, this would create: $tmpDirectoryStr$settings{OutputFileName} Note: This script relies on Perl Modules: Video::Frequencies, Video::ivtv, Config::IniFiles and Getopt::Long. END_OF_USAGE # handle user input here my %opts; #getopts('c:t:o:hd:W:H:s:T:D:vi:I:f:F:LRb:B:P:S', \%opts); GetOptions(\%opts, "channel|c=s", "duration|t=i", "output|o=s", "help|h", "input|d=s", "width|W=i", "height|H=i", "standard|s=s", "type|T=s", "directory|D=s", "version|v", "inputnum|i=i", "inputname|I=s", "freqtable|f=s", "frequency|F=i", "list-freqtable|L", "noreset|R", "bitrate|b=i", "peakbitrate|B=i", "profile|P=s@", "save|S", "aspect=i", "audio-bitmask=s", "bframes=i", "dnrmode=i", "dnrspatial=i", "dnrtemporal=i", "dnrtype=i", "framerate=i", "framespergop=i", "gopclosure=i", "pulldown=i", "capture-last-gop=i", "streamtype=i", "no-record", "directory-format=s", "date-format=s", "debug", "list-channels", "tuner-num=i", "list-inputs", "list-standards", "bitrate-mode=i", "output-settings=i", "output-settings-name=s", "output-settings-type=s"); if (scalar keys %opts == 0 && @ARGV == 0) { usage(0, ""); } foreach my $option (sort keys %opts) { my $found = 0; foreach my $mapName (keys %mappings) { if ($option =~ /^($mappings{$mapName})$/) { $settings{$mapName} = $opts{$option}; $found = 1; print "$mapName = '$opts{$option}'\n" if $settings{Debug}; } } if (!$found) { # handle the non-settings cases. if ($option =~ /^(L|list-freqtable)$/) { my $errStr = "\nAvailable Frequency Mappings:\n"; foreach my $name (sort keys %CHANLIST) { $errStr .= "$name\n"; } print "$versionStr\n$errStr"; exit 0; } elsif ($option eq "list-channels") { my $errStr = "\nAvailable Channels for $settings{FrequencyTable}:\n"; foreach my $name (sort { $a <=> $b } keys %{$CHANLIST{$settings{FrequencyTable}}}) { $errStr .= "$name\t= $CHANLIST{$settings{FrequencyTable}}->{$name}\n"; } print "$versionStr\n$errStr"; exit 0; } elsif ($option =~ /^(no-record)$/) { $settings{DontRecord} = 1; } elsif ($option =~ /^(S|save)$/) { $settings{UpdateConfigFile} = 1; } elsif ($option =~ /^(P|profile)$/) { @profileNames = @{$opts{$option}}; } elsif ($option =~ /^(v|version)$/) { print "$versionStr\n"; exit 0; } elsif ($option =~ /^(h|help)$/) { usage(0, ""); } elsif ($option =~ /^(list-inputs|list-standards)$/) { # do nothing for now since they will be handled later. } else { usage(1, "-$option is an unknown option!"); } } } if (@profileNames) { # loop over all profiles the user specified. foreach my $profileName (@profileNames) { print "profile = '$profileName'\n" if $settings{Debug}; # for now the profile can not be "defaults". if ($profileName eq "defaults") { error(1, "Profile = '$profileName' is invalid!"); } if (exists $configIni{$profileName}) { # update defaults that exist in this profile as long as the entry wasn't specified on the command line. my $profile = $profileName; foreach my $arg (keys %mappings) { # handle the long/short command option versions my $cmdSpecified = 0; foreach my $option (split(/\|/, $mappings{$arg})) { if (exists $opts{$option}) { $cmdSpecified = 1; last; } } #print "arg = '$arg', option = '$option'\n" if $settings{Debug}; if (exists $configIni{$profile}{$arg} && !$cmdSpecified) { $profileOverloads{$arg} = $settings{$arg}; # preserve the old value. $settings{$arg} = $configIni{$profile}{$arg}; print "settings{$arg} = '" . $settings{$arg} . "'\n" if $settings{Debug}; } } } else { if ($settings{UpdateConfigFile} && @profileNames == 1) { print "Warning: Profile = '$profileName' will be created.\n" if ($settings{Debug}); } else { error(1, "Profile = '$profileName' does not exist! You must specify -S/--save to create it."); } } } } # verify input if (@ARGV) { if (exists $opts{c} || exists $opts{channel}) { print "Warning: ignoring channel argument and using '$ARGV[0]' instead.\n"; } $settings{Channel} = $ARGV[0]; } my $directoryName; if (!$settings{DontRecord}) { print "RecordDuration = $settings{RecordDuration}\n" if $settings{Debug}; if ($settings{VideoType} !~ /^(mpeg|yuv)$/) { error(1, "Video Type = '$settings{VideoType}' is invalid!"); } if ($settings{VideoType} eq "yuv") { # see if we need to change our defaults. if (!exists $opts{o} && !exists $opts{output}) { $settings{OutputFileName} = "video.yuv"; } if (!exists $opts{d} && !exists $opts{input}) { if ( -e "/dev/.devfsd" ) { $settings{VideoDevice} = "/dev/v4l/yuv0"; } else { $settings{VideoDevice} = "/dev/yuv0"; } } } if ( ! -d "$settings{OutputDirectory}") { $result = `mkdir -p $settings{OutputDirectory}`; } # make directory $directoryName = formatDirectoryString(); $result=`mkdir -p $directoryName`; } # verify the output-settings options if ($settings{OutputSettings} !~ /^[01]$/) { error(1, "OutputSettings = '$settings{OutputSettings}' is invalid!"); } if ($settings{OutputSettings} && $settings{DontRecord}) { $settings{OutputSettings} = 0; # turn off feature since we are not recording. } if ($settings{OutputSettings}) { if ($settings{OutputSettingsName} !~ /^(.+\.settings)$/) { error(1, "OutputSettingsName = '$settings{OutputSettingsName}' is invalid! It must end in .settings."); } if ($settings{OutputSettingsType} !~ /^(shell|perl)$/) { error(1, "OutputSettingsType = '$settings{OutputSettingsType}' is invalid! It must be either 'shell' or 'perl'."); } sysopen($settingsFH, "$directoryName/$settings{OutputSettingsName}", O_CREAT | O_WRONLY) or die "Error creating file '$settings{OutputSettingsName}': $!\n"; outputSettingSetup(); } if ( ! -c "$settings{VideoDevice}") { error(1, "Video Dev = '$settings{VideoDevice}' is invalid! $!"); } # now that the video device has been semi validated, we can use it to lookup # the inputs, standards, etc. and use that for validating some of the following # pieces of user input. sysopen($tuner, $settings{VideoDevice}, O_RDWR) or die "Error unable to open '$settings{VideoDevice}': $!"; my $tunerFD = fileno($tuner); outputSetting("VideoDevice"); # get the current capabilities. @capabilities = $ivtvObj->getCapabilities($tunerFD); if (@capabilities != keys %{$ivtvObj->{capIndexes}}) { error(1, "getCapabilities() failed!"); } # calculate the driver version info. my $driverVersionHex = sprintf("%08x", $capabilities[$ivtvObj->{capIndexes}{version}]); $driverVersionHex =~ /^(\d{4})(\d{2})(\d{2})$/; my $driverVersionMajor = int($1); my $driverVersionMinor = int($2); my $driverVersionPatch = int($3); my $driverVersionStr = $driverVersionMajor . "." . $driverVersionMinor . "." . $driverVersionPatch; $settings{v4l2DriverVersion} = $capabilities[$ivtvObj->{capIndexes}{version}]; $settings{v4l2DriverVersionStr} = $driverVersionStr; $settings{v4l2Driver} = $capabilities[$ivtvObj->{capIndexes}{driver}]; outputSetting("v4l2Driver"); outputSetting("v4l2DriverVersion"); outputSetting("v4l2DriverVersionStr"); if ($settings{Debug}) { print "V4l2 Capabilities: driver='$capabilities[$ivtvObj->{capIndexes}{driver}]', version='$capabilities[$ivtvObj->{capIndexes}{version}]', '$driverVersionStr'\n"; } if ($capabilities[$ivtvObj->{capIndexes}{driver}] ne "ivtv") { $settings{UsingIvtvDriver} = 0; # we can't use the ivtv "enhancements". print "Warning: V4l2 driver = '$capabilities[$ivtvObj->{capIndexes}{driver}]' does not support the ivtv \"enhancements\"!\n"; print " All codec and ivtv specific options will be ignored.\n\n"; } elsif ($capabilities[$ivtvObj->{capIndexes}{version}] <= 265) { $settings{CaptureLastGOP} = 0; # we can't use the ivtv GOP_END feature. print "Warning: ivtv driver is not new enough to use the GOP_END feature!\n"; } $ivtvVersion = $capabilities[$ivtvObj->{capIndexes}{version}]; my $i; # get the current video standard $std = $ivtvObj->getStandard($tunerFD); if ($std > 0) { printf("Standard: 0x%08x\n",$std) if ($settings{Debug}); } else { die "Error: getStandard() failed!\n"; } # get the current input $curinput = $ivtvObj->getInput($tunerFD); if ($curinput < 0) { die "Error: getInput() failed!\n"; } printf("Input: 0x%08x\n",$curinput) if ($settings{Debug}); # flags to indicate when we should stop reading from the card. my $done=0; my $stopGOP=0; # indicates if we are asking for the Last GOP my $endStream=0; # indicates if we are in the final read state. # Standards for ($i=0; !$done; ++$i) { my($index,$std_id,$name,$frameperiod_n,$frameperiod_d,$framelines) = $ivtvObj->enumerateStandard($tunerFD, $i); if ($index == -1) { $done = 1; } else { printf("%d 0x%08x %s %d/%d %d\n",$index,$std_id,$name,$frameperiod_n,$frameperiod_d,$framelines) if ($settings{Debug}); push @standards, [($name,$std_id)]; $name2std{$name} = $std_id; if( (($std_id & $std) == $std)) { $curstd = $name; $curStandard = $std; } } } if (exists $opts{'list-standards'}) { print "$versionStr\n"; print "Available Video Standards:\n"; foreach my $standard (@standards) { print "$standard->[0]\n"; } exit 0; } $done=0; # Inputs for ($i=0; !$done; ++$i) { my($index,$name,$type,$audioset,$tuner,$std,$status) = $ivtvObj->enumerateInput($tunerFD, $i); if ($index == -1) { $done = 1; } else { push @inputs, $name; $name2input{$name} = $index; } } $curinputName = $inputs[$curinput]; if (exists $opts{'list-inputs'}) { print "$versionStr\n"; print "Available Inputs:\n"; my $counter = 0; foreach my $input (@inputs) { print "$counter: $input\n"; $counter++; } exit 0; } if ($settings{UsingIvtvDriver}) { # get the current Codec Info @codecInfo = $ivtvObj->getCodecInfo($tunerFD); if (@codecInfo != keys %{$ivtvObj->{codecIndexes}}) { error(1, "getCodecInfo() failed!"); } @newCodecInfo = $ivtvObj->getCodecInfo($tunerFD); if (@newCodecInfo != keys %{$ivtvObj->{codecIndexes}}) { error(1, "getCodecInfo() failed!"); } } # finish validating the user input. if (!$settings{DontRecord}) { if ($settings{RecordDuration} !~ /^(\d+)$/) { error(1, "Time = '$settings{RecordDuration}' is invalid!"); } outputSetting("RecordDuration"); outputSetting("OutputDirectory"); # assume for now we are only generating mpeg files. if (($settings{VideoType} eq "mpeg" && $settings{OutputFileName} !~ /^.+\.mpg$/) || ($settings{VideoType} eq "yuv" && $settings{OutputFileName} !~ /^.+\.yuv$/)) { error(1, "Output = '$settings{OutputFileName}' is invalid!"); } outputSetting("VideoType"); outputSetting("OutputFileName"); if ($settings{DateTimeFormatString} !~ /^(\+((\%.)|.)+)$/) { usage(1, "Date Format String = '$settings{DateTimeFormatString}' is invalid!"); } outputSetting("DateTimeFormatString"); } if ($settings{VideoWidth} !~ /^(\d+)$/) { error(1, "Width = '$settings{VideoWidth}' is invalid!"); } outputSetting("VideoWidth"); if ($settings{VideoHeight} !~ /^(\d+)$/) { error(1, "Height = '$settings{VideoHeight}' is invalid!"); } outputSetting("VideoHeight"); if (!exists $name2std{$settings{VideoStandard}}) { my $validStandards = join(", ", keys(%name2std)); error(1, "Video Standard = '$settings{VideoStandard}' is invalid!\nValid Standards are: $validStandards"); } outputSetting("VideoStandard"); if (exists $opts{i} || exists $opts{inputnum} || ($settings{InputNum} != $name2input{$settings{InputName}} && exists $profileOverloads{InputNum})) { if ($settings{InputNum} < 0 || $settings{InputNum} >= scalar(@inputs)) { error(1, "Video Input = '$settings{InputNum}' is invalid!\nValid Inputs are from 0 - " . int(scalar(@inputs) - 1)); } $settings{InputName} = $inputs[$settings{InputNum}]; } if ((exists $opts{I} || exists $opts{inputname} || $settings{InputNum} != $name2input{$settings{InputName}}) && !(exists $opts{i} || exists $opts{inputnum})) { if (!exists $name2input{$settings{InputName}}) { my $validInputs = join(", ", @inputs); error(1, "Video Input Name = '$settings{InputName}' is invalid!\nValid Input Names are: $validInputs"); } $settings{InputNum} = $name2input{$settings{InputName}}; } outputSetting("InputName"); outputSetting("InputNum"); if (!exists $CHANLIST{$settings{FrequencyTable}}) { error(1, "Frequency Table = '$settings{FrequencyTable}' is invalid!"); } outputSetting("FrequencyTable"); # only validate the channel if the input is a tuner. if ($inputs[$settings{InputNum}] =~ /Tuner/) { if ($settings{TunerNum} !~ /^(\d)$/) { error(1, "TunerNum = '$settings{TunerNum}' is invalid!"); } if (exists $opts{F} || exists $opts{frequency} || $settings{Frequency}) # the user may have specified a Frequency in their config file { if ($settings{Frequency} !~ /^(\d+)$/) { error(1, "Frequency = '$settings{Frequency}' is invalid!"); } $settings{Channel} = "freq-$settings{Frequency}"; # make sure we output the channel part. } # now verify that the channel exists in the frequency table! else { if (!$settings{Channel}) { error(1, "channel = '$settings{Channel}' is invalid!"); } # first verify the freqency table is appropriate for the standard (NTSC, PAL, SECAM), # unless they specified the frequency to tune to. if ($settings{FrequencyTable} !~ /^(custom|$settings{VideoStandard})/i) { error(1, "You specified Video Standard '$settings{VideoStandard}' which is incompatible with Frequency Table '$settings{FrequencyTable}'!"); } if (!exists $CHANLIST{$settings{FrequencyTable}}->{$settings{Channel}}) { error(1, "Channel = '$settings{Channel}' does not exist in Frequency Table '$settings{FrequencyTable}'!"); } } outputSetting("Channel"); outputSetting("Frequency"); # get the current channel/frequency value. my $Frequency; if(($Frequency = $ivtvObj->getFrequency($tunerFD, $settings{TunerNum})) > 0) { my $freq = ($Frequency * 1000) / 16; print "freq = $freq\n" if ($settings{Debug}); # find the associated channel. if ((!exists $opts{F} && !exists $opts{frequency} && !$settings{Frequency}) && ($curstd eq $settings{VideoStandard}) ) { foreach my $chan (keys %{$CHANLIST{$settings{FrequencyTable}}}) { if ($CHANLIST{$settings{FrequencyTable}}->{$chan} == $freq) { $curChannel = $chan; } } print "curChannel = $curChannel\n" if ($settings{Debug}); } else { $curFrequency = $freq; } } elsif ($Frequency < 0) { die "Error: getFrequency() failed!\n"; } } else { # set the channel = "" so we know to ignore it. $settings{Channel} = ""; } if ($settings{UsingIvtvDriver}) { # validate the Codec related stuff. if ($settings{BitrateMode} !~ /^(0|1)$/) { error(1, "BitrateMode = '$settings{BitrateMode}' is invalid!"); } if ($settings{Bitrate} < $settings{minBitrate} || $settings{Bitrate} > $settings{maxBitrate}) { error(1, "Bitrate = '$settings{Bitrate}' is invalid!"); } if ($settings{PeakBitrate} < $settings{Bitrate}) { error(1, "PeakBitrate can not be less than Bitrate!"); } elsif ($settings{PeakBitrate} == $settings{Bitrate} && !$settings{BitrateMode} == 1) { error(1, "PeakBitrate can not be equal to Bitrate in VBR Mode!"); } elsif ($settings{PeakBitrate} < $settings{minPeakBitrate} || $settings{PeakBitrate} > $settings{maxPeakBitrate}) { error(1, "PeakBitrate = '$settings{PeakBitrate}' is invalid!"); } if ($settings{VideoStandard} !~ /^(NTSC)/) { my $warn = 0; if ($settings{Framerate} == 0) { $settings{Framerate} = 1; $warn = 1; } if ($settings{FramesPerGOP} == 15) { $settings{FramesPerGOP} = 12; $warn = 1; } if ($warn) { print "Warning: Setting Framerate/FramesPerGOP to PAL settings for Video Standard '$settings{VideoStandard}'!\n\nYou should either specify on the command line or in the ~/.ivtvrc config file.\n"; } } elsif ($settings{VideoStandard} =~ /^(NTSC)/) { my $warn = 0; if ($settings{Framerate} == 1) { $settings{Framerate} = 0; $warn = 1; } if ($settings{FramesPerGOP} == 12) { $settings{FramesPerGOP} = 15; $warn = 1; } if ($warn) { print "Warning: Setting Framerate/FramesPerGOP to NTSC settings for Video Standard '$settings{VideoStandard}'!\n\nYou should either specify on the command line or in the ~/.ivtvrc config file.\n"; } } if ($settings{StreamType} < 0 || $settings{StreamType} > 14) { error(1, "StreamType = '$settings{StreamType}' is invalid!"); } if ($settings{CaptureLastGOP} < 0 || $settings{CaptureLastGOP} > 1) { error(1, "CaptureLastGOP = '$settings{CaptureLastGOP}' is invalid!"); } outputSetting("BitrateMode"); outputSetting("Bitrate"); outputSetting("PeakBitrate"); outputSetting("SetMSPMatrix"); outputSetting("MSPInput"); outputSetting("MSPOutput"); outputSetting("Framerate"); outputSetting("FramesPerGOP"); outputSetting("Aspect"); outputSetting("AudioBitmask"); outputSetting("BFrames"); outputSetting("DNRMode"); outputSetting("DNRSpatial"); outputSetting("DNRTemporal"); outputSetting("DNRType"); outputSetting("GOPClosure"); outputSetting("Pulldown"); outputSetting("StreamType"); outputSetting("CaptureLastGOP"); } # update the config file if the user wants us to. if ($settings{UpdateConfigFile}) { my $profile; if (@profileNames > 1) { print "Warning: Not updating config file as you have more than 1 profile specified!\n"; } elsif (@profileNames == 1) { $profile = $profileNames[0]; } else { $profile = "defaults"; } if ($profile) { my $createProfile = (exists $configIni{$profile} ? 0 : 1); print "Creating Profile = '$profile': $createProfile\n" if ($settings{Debug}); if (!$settings{UseConfigFile}) { # we have to create the config file and tie to it. tie %configIni, 'Config::IniFiles', () or die "Error: Initializing config file '$settings{ConfigFileName}' failed! $!\n"; # now set the name to work with. tied(%configIni)->SetFileName($settings{ConfigFileName}) or die "Error: Setting config file to '$settings{ConfigFileName}' failed! $!\n"; $configIni{$profile} = {}; # make sure the section exists. } foreach my $arg (keys %mappings) { foreach my $option (split(/\|/, $mappings{$arg})) # handle the long/short command option versions { if (exists $configIni{$profile}{$arg} || $createProfile || exists $opts{$option}) { $configIni{$profile}{$arg} = $settings{$arg}; print "configIni{$profile}{$arg} = '" . $settings{$arg} . "'\n" if $settings{Debug}; last; } } } # write the config file out. tied(%configIni)->RewriteConfig or die "Error: Writing config file '$settings{ConfigFileName}' failed! $!\n"; } } # this hash keeps track of those values I have to set back. my %changedSettings = ( resolution => 0, standard => 0, VideoType => 0, InputNum => 0, Channel => 0, Frequency => 0, codec => 0, ); # change the channel if ($inputs[$settings{InputNum}] =~ /Tuner/) { if (exists $opts{F} || exists $opts{frequency} || $settings{Frequency}) { if ($settings{Frequency} != $curFrequency) { $changedSettings{Frequency} = 1; tuneFrequency($settings{Frequency}); } } else { if ($curstd ne $settings{VideoStandard}) { # we have to set the channel regardless. # but we want to tune back to the previous frequency. $changedSettings{Frequency} = 1; changeChannel($settings{Channel}); } elsif ($settings{Channel} ne $curChannel) { # otherwise we just changeChannel and restore the previous channel. $changedSettings{Channel} = 1; changeChannel($settings{Channel}); } } } # set the video standard if ($settings{VideoStandard} ne $curstd) { $changedSettings{standard} = 1; change_standard(); } # set the input if ($settings{InputNum} != $curinput || $settings{InputName} ne $curinputName) { $changedSettings{InputNum} = 1; if (!(exists $opts{i} || exists $opts{inputnum} || exists $opts{I} || exists $opts{inputname} || exists $profileOverloads{InputNum} || exists $profileOverloads{InputName})) # our defaults are different than the current values! { print "Warning: Changing input from '$curinputName' to'$settings{InputName}'.\n"; } change_input(); } # set the capture type # store the current width,height so we can restore afterwards my ($oldWidth, $oldHeight) = $ivtvObj->getResolution($tunerFD); print "oldWidth = '$oldWidth', oldHeight = '$oldHeight'\n" if ($settings{Debug}); if ($settings{VideoWidth} != $oldWidth || $settings{VideoHeight} != $oldHeight) { $changedSettings{resolution} = 1; } # specify the width,height to capture if ($changedSettings{resolution}) { $result = $ivtvObj->setResolution($tunerFD, $settings{VideoWidth}, $settings{VideoHeight}); if (not defined $result) { die "Error calling setResolution!\n"; } if (!$result) { die "Error in setResolution ioctl call!\n"; } } if ($settings{UsingIvtvDriver}) { # set the GOP_END flag if the user requested it. if ($ivtvVersion > 265) # > 0.1.9 { $result = $ivtvObj->setEndGOP($tunerFD, $settings{CaptureLastGOP}); if (!$result) { die "Error calling setEndGOP($settings{CaptureLastGOP})!\n"; } } # specify the codec options to capture mpeg's at. foreach my $codecName (keys %codecMappings) { my $codecIndex = $ivtvObj->{codecIndexes}{$codecMappings{$codecName}}; if ($codecInfo[$codecIndex] != $settings{$codecName}) { $changedSettings{codec} = 1; $newCodecInfo[$codecIndex] = $settings{$codecName}; print "new $codecName = '$settings{$codecName}', old $codecName = '$codecInfo[$codecIndex]'\n" if $settings{Debug}; } } } if ($changedSettings{codec}) { $result = $ivtvObj->setCodecInfo($tunerFD, @newCodecInfo); if (!$result) { die "Error calling setCodecInfo()!\n"; } } if (!$settings{DontRecord}) { close($settingsFH) if ($settings{OutputSettings}); # capture the video/audio to video.mpg captureVideo(directoryName => $directoryName, RecordDuration => $settings{RecordDuration}, OutputFileName => $settings{OutputFileName}, tuner => $tuner); } if ($settings{ResetCardSettings} && !$settings{DontRecord}) { # close and re-open the device since it appears to not like taking new settings if we ended capturing. close($tuner); sysopen($tuner, $settings{VideoDevice}, O_RDWR) or die "Error unable to open '$settings{VideoDevice}': $!"; $tunerFD = fileno($tuner); # restore Codec values if ($changedSettings{codec}) { $result = $ivtvObj->setCodecInfo($tunerFD, @codecInfo); if (!$result) { die "Error calling setCodecInfo()!\n"; } } # restore the previous input setting if ($changedSettings{InputNum}) { # reset back to the old input name $settings{InputName} = $curinputName; change_input(); } # restore the previous video standard if ($changedSettings{standard}) { $settings{VideoStandard} = $curstd; change_standard(); } # restore the previous width,height settings if ($changedSettings{resolution}) { $result = $ivtvObj->setResolution($tunerFD, $oldWidth, $oldHeight); if (not defined $result) { die "Error calling setResolution!\n"; } if (!$result) { die "Error in setResolution ioctl call! result = '$result', oldWidth = '$oldWidth', oldHeight = '$oldHeight'\n"; } } # restore the previous channel if ($changedSettings{Channel} && $curChannel > 0) { changeChannel($curChannel); } if ($changedSettings{Frequency} && $curFrequency > 0) { tuneFrequency($curFrequency); } } # close the tuner device close($tuner); exit 0; # usage(returnValue, ErrorString) # returnValue = 1 or 0 # ErrorString = message you want to tell the user, but only if returnValue = 1. sub usage { my $errorCode = shift; my $error = shift; print $usageStr; print "\nError: $error\n" if ($errorCode == 1); print "$error\n" if ($errorCode == 2); exit $errorCode; } # error(returnValue, ErrorString) # returnValue = 1 or 0 # ErrorString = message you want to tell the user. sub error { my $errorCode = shift; my $error = shift; print "$versionStr"; print "\nError: $error\n"; exit $errorCode; } # changes the input to $settings{InputNum} as long as it isn't = $curinput sub change_input { my $preinput = $name2input{$settings{InputName}}; if($preinput != $curinput) { $curinput = $preinput; print "input now $settings{InputName}, #$preinput\n" if ($settings{Debug}); my $result = $ivtvObj->setInput($tunerFD, $preinput); if (!$result) { die "Error: setInput($preinput) failed!\n"; } } } # changes the video standard to $settings{VideoStandard} as long as it isn't = $curstd sub change_standard { my $standard = $name2std{$settings{VideoStandard}}; if($standard != $curStandard) { $curStandard = $standard; print "standard now $settings{VideoStandard}, #$standard\n" if ($settings{Debug}); my $result = $ivtvObj->setStandard($tunerFD, $standard); if (!$result) { die "Error: setStandard($standard) failed!\n"; } } } # changes the channel # takes the channel to change sub changeChannel { my $ch = shift; my $freq = $CHANLIST{$settings{FrequencyTable}}->{$ch}; my $driverf = ($freq * 16)/1000; print "Ch.$ch: $freq $driverf\n" if ($settings{Debug}); if (!$ivtvObj->setFrequency($tunerFD, $settings{TunerNum}, $driverf)) { die "Error: changeChannel($ch) failed!\n"; } } # tunes to the specified frequency # takes the frequency to tune to sub tuneFrequency { my $freq = shift; my $driverf = ($freq * 16)/1000; print "freq: $freq $driverf\n" if ($settings{Debug}); if (!$ivtvObj->setFrequency($tunerFD, $settings{TunerNum}, $driverf)) { die "Error: tuneFrequency($freq) failed!\n"; } } my $done = 0; sub catch_alarm { if ($settings{CaptureLastGOP}) { $stopGOP = 1; # signal we need to stop the stream and capture the last GOP. } else { $done = 1; # signal we are done. } } # does the actual video capturing work. # takes directoryName, RecordDuration, OutputFileName, tuner sub captureVideo { my %args = ( @_ ); my $directoryName = $args{directoryName}; my $RecordDuration = $args{RecordDuration}; my $OutputFileName = $args{OutputFileName}; my $tuner = $args{tuner}; my $fname = "$directoryName/$OutputFileName"; # setup global variables, signal handlers, etc. $SIG{ALRM} = \&catch_alarm; $SIG{INT} = \&catch_alarm; # handle Ctrl-C # open the file for writing. sysopen(OUTPUT, "$fname", O_CREAT | O_WRONLY | O_LARGEFILE) or die "Error creating file '$fname': $!\n"; alarm($RecordDuration); my $buf = ""; while (!$done) { if ($stopGOP) { $stopGOP = 0; $ivtvObj->stopEncoding($tuner); $endStream = 1; $done = 1; # signal we are done after this loop. } # read from the device and write to the file. (16384) 32768 my $bytes = read($tuner, $buf, 16384); if (!$bytes && $endStream) { last; } print OUTPUT $buf; } # close the file close(OUTPUT); } # returns the formatted directory string sub formatDirectoryString { my $temp = $settings{DirectoryFormatString}; my $result = $settings{OutputDirectory}; my %lookupTable = ( "d" => `/bin/date "$settings{DateTimeFormatString}"`, "I" => $settings{InputName}, "c" => $settings{Channel}, ); # fixup the InputName value $lookupTable{I} =~ s/\s/_/g; # cleanup the trailing slash on the date chomp $lookupTable{d}; foreach my $option ("d", "I", "c") { $temp =~ s/\%$option/$lookupTable{$option}/g; } $result .= "/" . ($temp ? "$temp/" : ""); return $result; } sub outputSettingSetup { my $date = `/bin/date`; chomp $date; if ($settings{OutputSettingsType} eq "shell") { print $settingsFH "# Settings for Recording made on $date.\n"; } elsif ($settings{OutputSettingsType} eq "perl") { print $settingsFH "# Settings for Recording made on $date.\n"; print $settingsFH "my %settings = ();\n"; } } # outputs the specified setting and it's value to the # settings file represented by $settingsFH in the # specified language. sub outputSetting { my $setting = shift; my $value = $settings{$setting}; return if (!$settings{OutputSettings}); if ($settings{OutputSettingsType} eq "shell") { print $settingsFH "REC_" . uc($setting) . "=\"$value\"\n"; } elsif ($settings{OutputSettingsType} eq "perl") { print $settingsFH "\$settings{$setting} = \"$value\";\n"; } } ivtv-utils-1.4.1/utils/perl/ptune-ui.pl0000775000076400007640000003374411355717530016557 0ustar andyandy#!/usr/bin/perl use strict; use Tk; use Tk::Font; use Tk::BrowseEntry; use Getopt::Long qw(:config no_ignore_case bundling); use Video::Frequencies 0.03; use Video::ivtv 0.13; use Config::IniFiles; my $version="1.10"; # +--------------------------+ # | * tuner O comp. O svideo | # | ch: [ ] | # | | # | +---+ +---+ +---+ +---+ | # | | 1 | | 2 | | 3 | | ^ | | ch up # | +---+ +---+ +---+ +---+ | # | +---+ +---+ +---+ +---+ | # | | 4 | | 5 | | 6 | | v | | ch dn # | +---+ +---+ +---+ +---+ | # | +---+ +---+ +---+ +---+ | # | | 7 | | 8 | | 9 | | + | | fine up # | +---+ +---+ +---+ +---+ | # | +---+ +---+ +---+ +---+ | # | |100| | 0 | | | | - | | fine dn # | +---+ +---+ +---+ +---+ | # +--------------------------+ my $tvchan = "??"; my $state = 0; my $digits = 0; my $hundred = 0; my $prechan = 0; my $chan = -1; # state # 0 - ready for new input # 1 - inputing # fwd decl sub change_chan; sub change_input; my %settings = ( Channel => 73, # default to SCI-FI VideoStandard => "NTSC", VideoDevice => "/dev/video0", FrequencyTable => "ntsc-cable", # default to NTSC_CABLE mapping. ConfigFileName => "$ENV{HOME}/.ivtvrc", UseConfigFile => 0, UsingIvtvDriver => 1, # default to being able to use the ivtv "enhancements". # other settings Debug => 0, TunerNum => 0, ); # map the Settings/Config file parameter to the command line variable that specifies it. my %mappings = ( "VideoDevice" => "d|input", "FrequencyTable" => "f|freqtable", "Debug" => "debug", "TunerNum" => "tuner-num", ); my %configIni; # config hash we tie to for Config::IniFiles. my $ivtvObj = Video::ivtv->new(); # check for devfs support if ( -e "/dev/.devfsd" ) { $settings{VideoDevice} = "/dev/v4l/video0"; } # check for the config file if (-f $settings{ConfigFileName}) { $settings{UseConfigFile} = 1; # tie to it. tie %configIni, 'Config::IniFiles', (-file => $settings{ConfigFileName}) or die "Error: Opening config file '$settings{ConfigFileName}' failed! $!\n"; my $profile = "defaults"; if (exists $configIni{$profile}) { # update the defaults stored. foreach my $arg (keys %mappings) { if (exists $configIni{$profile}{$arg}) { $settings{$arg} = $configIni{$profile}{$arg}; #print "settings{$arg} = '" . $settings{$arg} . "'\n"; } } } else { print "Warning: config file '$settings{ConfigFileName}' exists but does not have the\n[$profile] section! Use record-v4l2.pl to create it.\n\n"; } } else # create the config file { print "Auto Creating config file $settings{ConfigFileName}...\n"; my $profile = "defaults"; # we have to create the config file and tie to it. tie %configIni, 'Config::IniFiles', () or die "Error: Initializing config file '$settings{ConfigFileName}' failed! $!\n"; # now set the name to work with. tied(%configIni)->SetFileName($settings{ConfigFileName}) or die "Error: Setting config file to '$settings{ConfigFileName}' failed! $!\n"; $configIni{$profile} = {}; # make sure the section exists. foreach my $arg (keys %mappings) { $configIni{$profile}{$arg} = $settings{$arg}; print "configIni{$profile}{$arg} = '" . $settings{$arg} . "'\n" if $settings{Debug}; } # write the config file out. tied(%configIni)->RewriteConfig or die "Error: Writing config file '$settings{ConfigFileName}' failed! $!\n"; } my $versionStr = "ptune-ui.pl $version for use with http://ivtv.sf.net/"; my $usageStr = <<"END_OF_USAGE"; $versionStr Usage: ptune-ui.pl [--input VIDEO_DEV] [--freqtable FREQENCY MAP] [--tuner-num TUNERNUM] [--help] [--version] [--debug] -d/--input VIDEO_DEV: video device to work with --tuner-num TUNERNUM: Specify the tuner to use. -f/--freqtable FREQUENCY MAP: Specify the frequency mapping to use. -h/--help: display this help -v/--version: display the version of this program --debug: turns on debug output Defaults: --input $settings{VideoDevice} --freqtable $settings{FrequencyTable} --tuner-num $settings{TunerNum} config file = '$settings{ConfigFileName}' Note: This script relies on Perl Modules: Video::Frequencies, Video::ivtv, Config::IniFiles, Getopt::Long and Perl::Tk. END_OF_USAGE # handle user input here my %opts; GetOptions(\%opts, "help|h", "input|d=s", "version|v", "freqtable|f=s", "debug", "tuner-num=i"); foreach my $option (keys %opts) { my $found = 0; foreach my $mapName (keys %mappings) { if ($option =~ /^($mappings{$mapName})$/) { $settings{$mapName} = $opts{$option}; $found = 1; print "$mapName = '$opts{$option}'\n" if $settings{Debug}; } } if (!$found) { # handle the non-settings cases. if ($option =~ /^(v|version)$/) { print "$versionStr\n"; exit 0; } elsif ($option =~ /^(h|help)$/) { usage(0, ""); } else { usage(1, "-$option is an unknown option!"); } } } # verify input if ( ! -c "$settings{VideoDevice}") { usage(1, "Video Dev = '$settings{VideoDevice}' is invalid! $!"); } if ($settings{TunerNum} !~ /^(\d)$/) { error(1, "TunerNum = '$settings{TunerNum}' is invalid!"); } # build up the "custom" frequency table my %customMap = (); foreach my $profileName (keys %configIni) { next if $profileName =~ /^(defaults)$/; if (exists $configIni{$profileName}{Frequency}) { $customMap{$profileName} = $configIni{$profileName}{Frequency}; } } $CHANLIST{custom} = \%customMap; if (!exists $CHANLIST{$settings{FrequencyTable}}) { usage(1, "Frequency Table = '$settings{FrequencyTable}' is invalid!"); } # enumerations my @standards; my %name2std; my @inputs; my %name2input; # Current settings (Input, Channel, Standard) my $input = 0; my $curinput; my $frequency; my $std; my $curstd = "???"; my $curfreqtable = $settings{FrequencyTable}; my $curchannel = ""; my $curFreq = 0; my $tuner; my $err; my $v4l2input; my $tunerFD; # card probe flag if (1) { ## ## probe the card ## open($tuner, "<$settings{VideoDevice}") or die "unable to open: $!"; $tunerFD = fileno($tuner); my $i; $err=0; # Capabilities and Is it V4L2 compat? # get the current capabilities. my @capabilities = $ivtvObj->getCapabilities($tunerFD); if (@capabilities != keys %{$ivtvObj->{capIndexes}}) { error(1, "getCapabilities() failed!"); } if ($capabilities[$ivtvObj->{capIndexes}{driver}] ne "ivtv") { $settings{UsingIvtvDriver} = 0; # we can't use the ivtv "enhancements". print "Warning: V4l2 driver = '$capabilities[$ivtvObj->{capIndexes}{driver}]' does not support the ivtv \"enhancements\"!\n"; print " All codec related options will be ignored.\n\n"; } # get the current video standard $std = $ivtvObj->getStandard($tunerFD); if ($std > 0) { printf("Standard: 0x%08x\n",$std) if ($settings{Debug}); } else { die "Error: getStandard() failed!\n"; } # get the current input $input = $ivtvObj->getInput($tunerFD); if ($input < 0) { die "Error: getInput() failed!\n"; } printf("Input: 0x%08x\n",$input) if ($settings{Debug}); my $done=0; # Standards for ($i=0; !$done; ++$i) { my($index,$std_id,$name,$frameperiod_n,$frameperiod_d,$framelines) = $ivtvObj->enumerateStandard($tunerFD, $i); if ($index == -1) { $done = 1; } else { printf("%d 0x%08x %s %d/%d %d\n",$index,$std_id,$name,$frameperiod_n,$frameperiod_d,$framelines) if ($settings{Debug}); push @standards, [($name,$std_id)]; $name2std{$name} = $std_id; if( (($std_id & $std) == $std)) { $curstd = $name; $settings{VideoStandar} = $name; } } } $done=0; # Inputs for ($i=0; !$done; ++$i) { my($index,$name,$type,$audioset,$tuner,$std,$status) = $ivtvObj->enumerateInput($tunerFD, $i); if ($index == -1) { $done = 1; } else { push @inputs, $name; $name2input{$name} = $index; } } $curinput = $inputs[$input]; # frequency's a little funny, you need to specify a valid tuner. WTF? } else { $input = 2; @inputs = ( "Composite 1", "Composite 2", "Tuner 1", "SVideo 1", "SVideo 2" ); } my $mw = MainWindow->new; my $i=0; my $j=0; my @frame; my @blab = ("1","2","3","^", "4","5","6","v", "7","8","9","+", "100","0"," ","-"); # radio, entry, keypad for $i (0..1) { $frame[$i] = $mw->Frame( -borderwidth => 0 ); $frame[$i]->pack( -fill => 'x' ); } $frame[2] = $mw->Frame( -borderwidth => 0 ); $frame[2]->pack( -fill => "both", -expand => 1 ); $i = 0; my @wid; # foreach my $label (("Tuner","Comp.","SVideo")) { # $wid[$i] = $frame[0]->Radiobutton( # -text => $label, # -variable => \$input, # -command => [\&change_input], # -value => $i ); # $wid[$i]->pack( -side => "left" ); # ++$i; # } my $label; # -state => "readonly", my $sentry = $frame[0]->BrowseEntry(-state => "readonly", -browsecmd => \&change_std, -variable => \$curstd); foreach $label (@standards) { $sentry->insert( "end", $label->[0] ); } $sentry->pack( -side => "left", -fill => "x", -expand => 1 ); my $bentry = $frame[0]->BrowseEntry(-state => "readonly", -browsecmd => \&change_input, -variable => \$curinput); foreach $label (@inputs) { $bentry->insert( "end", $label ); } $bentry->pack( -side => "left", -fill => "x", -expand => 1 ); my $fentry = $frame[1]->BrowseEntry(-state => "readonly", -browsecmd => \&change_freqtable, -variable => \$curfreqtable); foreach $label (sort keys %CHANLIST) { $fentry->insert( "end", $label ); } $fentry->pack( -side => "left", -fill => "x", -expand => 1 ); my $centry = $frame[1]->BrowseEntry(-state => "readonly", -browsecmd => \&change_channel, -variable => \$curchannel); foreach $label (sort { $a <=> $b } keys %{$CHANLIST{$curfreqtable}}) { $centry->insert( "end", $label ); } $centry->pack( -side => "left", -fill => "x", -expand => 1 ); my $efont = $mw->Font( -size => 24 ); my $entry = $frame[1]->Entry( -state => "disabled", -background => "white", -justify => "right", -font => \$efont, -textvariable => \$tvchan ); $entry->pack( -side => "left", -fill => "x", -expand => 1 ); # keypad frame $frame[3] = $frame[2]->Frame( -borderwidth => 0 ); $frame[3]->pack( -side=> "left", -fill => "both", -expand => 1 ); $j=3; for $i (4..7) { $frame[$i] = $frame[3]->Frame( -borderwidth => 0 ); for my $k (0..3) { $wid[$j] = $frame[$i]->Button( -text => $blab[$j-3], -command => [\&change_chan,$blab[$j-3]], -width => 1 ); $wid[$j]->pack( -side => "left", -fill => "both", -expand => 1 ); ++$j; } $frame[$i]->pack( -fill => "both", -expand => 1 ); } # enter button # $wid[3] = $frame[2]->Button( -text => "Enter" ); # $wid[3]->pack( -side => "left", -fill => 'y' ); MainLoop; sub do_chan { if($prechan) { if ($prechan =~ /^(\d+)$/) { $chan = $prechan + (100*$hundred); } else { $chan = $prechan; # string channel. } my $freq = $CHANLIST{$settings{FrequencyTable}}->{$chan}; if ($freq) { my $drfreq = ($freq * 16)/1000; $curFreq = $freq; if (!$ivtvObj->setFrequency($tunerFD, $settings{TunerNum}, $drfreq)) { die "Error: changeChannel($chan) failed!\n"; } print "Channel changed to $chan, freq = '$freq'\n"; } else { print "Channel $chan doesn't exist in $settings{FrequencyTable}!\n"; } } $tvchan = ($chan =~ /^(-1)$/)?"??":$chan; $prechan = 0; $hundred = 0; $state = 0; $digits = 0; } sub tuneFrequency { my $drfreq = ($curFreq * 16)/1000; if (!$ivtvObj->setFrequency($tunerFD, $settings{TunerNum}, $drfreq)) { die "Error: setFrequency($drfreq) failed!\n"; } print "Frequency tuned to '$curFreq'\n"; } sub change_chan { my ($key) = @_; print "channel input $key\n"; if( $key =~ /[ v^]/ ) { if( $key eq ' ' ) { $prechan = 0; } elsif( $key eq '^' ) { $prechan = $chan + 1 if ($chan =~ /^(\d+)$/); } elsif( $key eq 'v' ) { $prechan = $chan - 1 if ($chan =~ /^(\d+)$/); } do_chan(); } elsif( $key =~ /[\-+]/ ) { $curFreq += 1 if ($key eq "+"); $curFreq -= 1 if ($key eq "-" && $curFreq > 1); tuneFrequency(); } elsif( $key == 100 ) { ++$state; $hundred = 1; $tvchan = $prechan + 100*$hundred; } else { $prechan = ($prechan * 10) + $key; $tvchan = $prechan + 100*$hundred; ++$state; if(++$digits>1) { do_chan(); } } if($state == 1) { $entry->configure( -background => '#e0ffe0' ); } elsif ( $state == 0 ) { $entry->configure( -background => 'white' ); } } sub change_input { my $preinput = $name2input{$curinput}; if($preinput != $input) { $input = $preinput; print "input now $curinput, #$preinput\n"; my $result = $ivtvObj->setInput($tunerFD, $input); if (!$result) { die "Error: setInput($input) failed!\n"; } } } sub change_std { my $standard = $name2std{$curstd}; if($standard != $std) { $std = $standard; print "standard now $curstd, #$standard\n"; my $result = $ivtvObj->setStandard($tunerFD, $standard); if (!$result) { die "Error: setStandard($standard) failed!\n"; } } } sub change_freqtable { if ($curfreqtable ne $settings{FrequencyTable}) { $settings{FrequencyTable} = $curfreqtable; print "frequency table now $curfreqtable\n"; # flush the contents of the $centry drop-down combo # and re-populate with the new frequency table contents. $centry->delete(0, 'end'); foreach my $label (sort { $a <=> $b } keys %{$CHANLIST{$curfreqtable}}) { $centry->insert( "end", $label ); } } } # changes to the selected channel from the drop-down. sub change_channel { $prechan = $curchannel; do_chan(); } # usage(returnValue, ErrorString) # returnValue = 1 or 0 # ErrorString = message you want to tell the user, but only if returnValue = 1. sub usage { my $errorCode = shift; my $error = shift; print $usageStr; print "\nError: $error\n" if ($errorCode == 1); print "$error\n" if ($errorCode == 2); exit $errorCode; } __END__ ivtv-utils-1.4.1/utils/perl/ptune.pl0000775000076400007640000002602211355717530016133 0ustar andyandy#!/usr/bin/perl # # $Header: /cvsroot/ivtv/ivtv/ivtv/utils/ptune.pl,v 1.12 2003/07/16 03:30:39 pcxuser Exp $ # use strict; use Getopt::Long qw(:config no_ignore_case bundling); use Video::Frequencies; use Video::ivtv 0.13; use Config::IniFiles; my $version="1.11"; my %settings = ( Channel => 4, # default to the ivtv default channel VideoDevice => "/dev/video0", FrequencyTable => "ntsc-cable", # default to NTSC_CABLE mapping. Frequency => "", ConfigFileName => "$ENV{HOME}/.ivtvrc", UseConfigFile => 0, UsingIvtvDriver => 1, # default to being able to use the ivtv "enhancements". # other settings Debug => 0, TunerNum => 0, ); # map the Settings/Config file parameter to the command line variable that specifies it. my %mappings = ( "Channel" => "c|channel", "VideoDevice" => "d|input", "FrequencyTable" => "f|freqtable", "Frequency" => "F|frequency", "Debug" => "debug", "TunerNum" => "tuner-num", ); my @profileNames=(); # list of user defined sections to work with in the config file. my %configIni; # config hash we tie to for Config::IniFiles. my $ivtvObj = Video::ivtv->new(); # check for devfs support if ( -e "/dev/.devfsd" ) { $settings{VideoDevice} = "/dev/v4l/video0"; } # check for the config file if (-f $settings{ConfigFileName}) { $settings{UseConfigFile} = 1; # tie to it. tie %configIni, 'Config::IniFiles', (-file => $settings{ConfigFileName}) or die "Error: Opening config file '$settings{ConfigFileName}' failed! $!\n"; my $profile = "defaults"; if (exists $configIni{$profile}) { # update the defaults stored. foreach my $arg (keys %mappings) { if (exists $configIni{$profile}{$arg}) { $settings{$arg} = $configIni{$profile}{$arg}; #print "settings{$arg} = '" . $settings{$arg} . "'\n"; } } } else { print "Warning: config file '$settings{ConfigFileName}' exists but does not have the\n[$profile] section! Use record-v4l2.pl to create it.\n\n"; } } else # create the config file { print "Auto Creating config file $settings{ConfigFileName}...\n"; my $profile = "defaults"; # we have to create the config file and tie to it. tie %configIni, 'Config::IniFiles', () or die "Error: Initializing config file '$settings{ConfigFileName}' failed! $!\n"; # now set the name to work with. tied(%configIni)->SetFileName($settings{ConfigFileName}) or die "Error: Setting config file to '$settings{ConfigFileName}' failed! $!\n"; $configIni{$profile} = {}; # make sure the section exists. foreach my $arg (keys %mappings) { $configIni{$profile}{$arg} = $settings{$arg}; print "configIni{$profile}{$arg} = '" . $settings{$arg} . "'\n" if $settings{Debug}; } # write the config file out. tied(%configIni)->RewriteConfig or die "Error: Writing config file '$settings{ConfigFileName}' failed! $!\n"; } # build up the "custom" frequency table my %customMap = (); foreach my $profileName (keys %configIni) { next if $profileName =~ /^(defaults)$/; if (exists $configIni{$profileName}{Frequency}) { $customMap{$profileName} = $configIni{$profileName}{Frequency}; } } $CHANLIST{custom} = \%customMap; my $versionStr = "ptune.pl $version for use with http://ivtv.sf.net/"; my $usageStr = <<"END_OF_USAGE"; $versionStr Usage: ptune.pl [--channel CHANNEL] [--input VIDEO_DEV] [--freqtable FREQENCY MAP] [--frequency FREQUENCY] [--profile PROFILE] [--list-freqtable] [--list-channels] [--tuner-num TUNERNUM] [--help] [--version] [--debug] -c/--channel CHANNEL: channel number to switch to NOTE: You can also specify the channel by itself. Ex. record-v4l2.pl 73 would change to channel 73 using the default settings or the settings from your ~/.ivtvrc config file. -d/--input VIDEO_DEV: video device to work with -f/--freqtable FREQUENCY MAP: Specify the frequency mapping to use. -F/--frequency FREQUENCY: Specify the frequency to tune to. ex. 517250 = NTSC Cable 73 (SCiFi) --tuner-num TUNERNUM: Specify the tuner to use. -L/--list-freqtable: list all available frequency mappings that Video::Frequencies knows --list-channels: lists all channels and their frequencies for the specified frequency table being used. -P/--profile PROFILE: Override defaults and command line values with the config entries in the section labeled [PROFILE] from the config file $settings{ConfigFileName}. Examples: -P NTSC, -P 22 You can specify this option multiple times and each successive profile will overlay the defaults and any previous profiles. -h/--help: display this help -v/--version: display the version of this program --debug: turns on debug output Notes: If you specify both -c/--channel and -F/--frequency then -F/--frequency will take precedence. Defaults: --channel $settings{Channel} --input $settings{VideoDevice} --freqtable $settings{FrequencyTable} --tuner-num $settings{TunerNum} config file = '$settings{ConfigFileName}' Note: This script relies on Perl Modules: Video::Frequencies, Video::ivtv, Config::IniFiles and Getopt::Long. END_OF_USAGE # handle user input here my %opts; #getopts('c:hd:vf:F:L', \%opts); GetOptions(\%opts, "channel|c=s", "help|h", "input|d=s", "version|v", "freqtable|f=s", "frequency|F=i", "list-freqtable|L", "list-channels", "debug", "profile|P=s@", "tuner-num=i"); if (scalar keys %opts == 0 && @ARGV == 0) { usage(0, ""); } foreach my $option (sort keys %opts) { my $found = 0; foreach my $mapName (keys %mappings) { if ($option =~ /^($mappings{$mapName})$/) { $settings{$mapName} = $opts{$option}; $found = 1; print "$mapName = '$opts{$option}'\n" if $settings{Debug}; } } if (!$found) { # handle the non-settings cases. if ($option =~ /^(L|list-freqtable)$/) { my $errStr = "\nAvailable Frequency Mappings:\n"; foreach my $name (sort keys %CHANLIST) { $errStr .= "$name\n"; } print "$versionStr\n$errStr"; exit 0; } elsif ($option eq "list-channels") { my $errStr = "\nAvailable Channels for $settings{FrequencyTable}:\n"; foreach my $name (sort { $a <=> $b } keys %{$CHANLIST{$settings{FrequencyTable}}}) { $errStr .= "$name\t= $CHANLIST{$settings{FrequencyTable}}->{$name}\n"; } print "$versionStr\n$errStr"; exit 0; } elsif ($option =~ /^(P|profile)$/) { @profileNames = @{$opts{$option}}; } elsif ($option =~ /^(v|version)$/) { print "$versionStr\n"; exit 0; } elsif ($option =~ /^(h|help)$/) { usage(0, ""); } else { usage(1, "-$option is an unknown option!"); } } } if (@profileNames) { # loop over all profiles the user specified. foreach my $profileName (@profileNames) { print "profile = '$profileName'\n" if $settings{Debug}; # for now the profile can not be "defaults". if ($profileName eq "defaults") { error(1, "Profile = '$profileName' is invalid!"); } if (exists $configIni{$profileName}) { # update defaults/override command line arguments that exist in this profile. my $profile = $profileName; foreach my $arg (keys %mappings) { foreach my $option (split(/\|/, $mappings{$arg})) # handle the long/short command option versions { #print "arg = '$arg', option = '$option'\n" if $settings{Debug}; if (exists $configIni{$profile}{$arg} && !(exists $opts{$option})) { $settings{$arg} = $configIni{$profile}{$arg}; print "settings{$arg} = '" . $settings{$arg} . "'\n" if $settings{Debug}; last; } } } } else { error(1, "Profile = '$profileName' does not exist!\n\nYou must use record-v4l2.pl and specify -S/--save to create it\nor manually edit the config file and add the section."); } } } # verify input if (@ARGV) { if (exists $opts{c} || exists $opts{channel}) { print "Warning: ignoring channel argument and using '$ARGV[0]' instead.\n"; } $settings{Channel} = $ARGV[0]; } if ( ! -c "$settings{VideoDevice}") { usage(1, "Video Dev = '$settings{VideoDevice}' is invalid! $!"); } if ($settings{TunerNum} !~ /^(\d)$/) { error(1, "TunerNum = '$settings{TunerNum}' is invalid!"); } if (!exists $CHANLIST{$settings{FrequencyTable}}) { usage(1, "Frequency Table = '$settings{FrequencyTable}' is invalid!"); } my $freq; if (exists $opts{F} || exists $opts{frequency} || $settings{Frequency}) # the user may have specified a Frequency in their config file { if ($settings{Frequency} !~ /^(\d+)$/) { usage(1, "Frequency = '$settings{Frequency}' is invalid!"); } $freq = $settings{Frequency}; } # now verify that the channel exists in the frequency table! else { if (!$settings{Channel}) { usage(1, "channel = '$settings{Channel}' is invalid!"); } if (!exists $CHANLIST{$settings{FrequencyTable}}->{$settings{Channel}}) { usage(1, "Channel = '$settings{Channel}' does not exist in Frequency Table '$settings{FrequencyTable}'!"); } $freq = $CHANLIST{$settings{FrequencyTable}}->{$settings{Channel}}; } my $driverf = ($freq * 16)/1000; print "" . ((exists $opts{F} || exists $opts{frequency} || $settings{Frequency}) ? "Frequency" : "Ch.$settings{Channel}") . ": $freq $driverf\n"; open(my $tuner, "<$settings{VideoDevice}") or die "unable to open: $!"; my $tunerFD = fileno($tuner); # get the current capabilities. my @capabilities = $ivtvObj->getCapabilities($tunerFD); if (@capabilities != keys %{$ivtvObj->{capIndexes}}) { error(1, "getCapabilities() failed!"); } if ($capabilities[$ivtvObj->{capIndexes}{driver}] ne "ivtv") { $settings{UsingIvtvDriver} = 0; # we can't use the ivtv "enhancements". print "Warning: V4l2 driver = '$capabilities[$ivtvObj->{capIndexes}{driver}]' does not support the ivtv \"enhancements\"!\n"; print " All codec related options will be ignored.\n\n"; } if (!$ivtvObj->setFrequency($tunerFD, $settings{TunerNum}, $driverf)) { die "Error: setFrequency($driverf) failed!\n"; } close($tuner); # usage(returnValue, ErrorString) # returnValue = 1 or 0 # ErrorString = message you want to tell the user, but only if returnValue = 1. sub usage { my $errorCode = shift; my $error = shift; print $usageStr; print "\nError: $error\n" if ($errorCode == 1); print "$error\n" if ($errorCode == 2); exit $errorCode; } # error(returnValue, ErrorString) # returnValue = 1 or 0 # ErrorString = message you want to tell the user. sub error { my $errorCode = shift; my $error = shift; print "$versionStr"; print "\nError: $error\n"; exit $errorCode; } # VIDIOCSFREQ = _IOW('v',15,ulong) #.......o .......o .......o .......o #01000000 00000100 01110110 00000111 #40 04 76 0f __END__ # use Video::Capture::V4l; # my $tuner = new Video::Capture::V4l # or die "unable to open device: $!"; # set channel # set tuner std # $tuner->freq($freq); ivtv-utils-1.4.1/utils/perl/config-editor.pl0000775000076400007640000004564011355717530017540 0ustar andyandy#!/usr/bin/perl # config-editor.pl created by James A. Pattie 2003-06-11 # Copyright 2003, released under the GPL. # Purpose: to provide a graphical editor for the ~/.ivtvrc config file used # by the perl scripts of the ivtv project. # # You can always get the latest version of the script from cvs at # http://ivtv.sourceforge.net/ # # 20030611 - 1.0 - Initial version that builds the framework. # 20030626 - 1.1 - Updated to cover the Audio -> AudioBitmask changes and config file versioning. # 20030713 - 1.2 - Updated to cover the MSP Matrix options and config file version change. # 20040613 - 1.3 - Updated to cover the MSP Matrix options being gone and the new GOP_END ioctl. use strict; use Tk; use Tk::Font; use Tk::BrowseEntry; use Getopt::Long qw(:config no_ignore_case bundling); use Video::Frequencies 0.03; use Config::IniFiles; my $version="1.3"; my $cfgVersion = "3"; my $cfgVersionStr = "_configVersion_"; # hopefully unique [defaults] value to let me know what version the config file is. my %settings = ( ConfigFileName => "$ENV{HOME}/.ivtvrc", # other settings Debug => 0, ); # map the Settings parameter to the command line variable that specifies it. my %mappings = ( "Debug" => "debug", ); my %defaultSettings = ( Channel => 4, # default to the ivtv default channel RecordDuration => 3595, # default to 59 minutes 55 seconds (in seconds) - This lets 2 back to back cron jobs work! InputNum => 0, # TV-Tuner 1 InputName => "Tuner 1", OutputDirectory => ".", VideoDevice => "/dev/video0", VideoWidth => "720", # 720x480-fullscreen NTSC VideoHeight => "480", VideoStandard => "NTSC", # NTSC, PAL or SECAM VideoType => "mpeg", # mpeg, yuv Bitrate => "6500000", PeakBitrate => "8000000", # peak bitrate Aspect => 2, AudioBitmask => 0x00e9, BFrames => 3, DNRMode => 0, DNRSpatial => 0, DNRTemporal => 0, DNRType => 0, Framerate => 0, FramesPerGOP => 15, GOPClosure => 1, Pulldown => 0, StreamType => 0, # 10 = DVD format (almost) OutputFileName => "video.mpg", FrequencyTable => "ntsc-cable", # default to NTSC_CABLE mapping. Frequency => "", # user specified frequency. ResetCardSettings => 1, DontRecord => 0, # default to always recording data. DirectoryFormatString => "%I-%c-%d", # format string used to define the sub directory under OutputDirectory DateTimeFormatString => "+%Y%m%d-%H%M", # format string used to represent the date/time if the user wants it in their DirectoryFormatString # other settings CaptureLastGOP => 1, # default to trying to Capture the Last GOP of the encoder stream. Debug => 0, TunerNum => 1, ); my %configIni; # config hash we tie to for Config::IniFiles. my $changesUnsaved = 0; # keeps track of the current state of the config file (if it needs to be saved) # global variables my $profile = ""; my $attribute = ""; my $attributeValue = ""; # check for devfs support if ( -e "/dev/.devfsd" ) { $defaultSettings{VideoDevice} = "/dev/v4l/video0"; } # check for the config file if (-f $settings{ConfigFileName}) { # tie to it. tie %configIni, 'Config::IniFiles', (-file => $settings{ConfigFileName}) or die "Error: Opening config file '$settings{ConfigFileName}' failed! $!\n"; my $profile = "defaults"; if (exists $configIni{$profile}) { my $saveFile = 0; # check version of the config file. if (!exists $configIni{$profile}{$cfgVersionStr}) { print "Updating config file to version 1...\n"; # first version config file! Update the Audio -> AudioBitmask entries. $configIni{$profile}{$cfgVersionStr} = $cfgVersion; # find all entries that have Audio and move to AudioBitmask. foreach my $p (keys %configIni) { if (exists $configIni{$p}{Audio}) { $configIni{$p}{AudioBitmask} = $configIni{$p}{Audio}; delete $configIni{$p}{Audio}; } } $saveFile = 1; # signal we need to save the config changes. } if ($configIni{$profile}{$cfgVersionStr} != $cfgVersion) { # we need to upgrade if ($configIni{$profile}{$cfgVersionStr} == 1) { print "Updating config file to version 2...\n"; # add the MSP Matrix related options. $configIni{$profile}{SetMSPMatrix} = $settings{SetMSPMatrix}; $configIni{$profile}{MSPInput} = $settings{MSPInput}; $configIni{$profile}{MSPOutput} = $settings{MSPOutput}; $configIni{$profile}{MSPSleep} = $settings{MSPSleep}; $configIni{$profile}{$cfgVersionStr} = 2; $saveFile = 1; } if ($configIni{$profile}{$cfgVersionStr} == 2) { print "Updating config file to version 3...\n"; # remove the MSP Matrix related options from all profiles. foreach my $p (keys %configIni) { foreach my $k (qw(SetMSPMatrix MSPInput MSPOutput MSPSleep)) { if (exists $configIni{$p}{$k}) { delete $configIni{$p}{$k}; } } } $configIni{$profile}{CaptureLastGOP} = 1; $configIni{$profile}{$cfgVersionStr} = 3; $saveFile = 1; } } if ($saveFile) { # now save the updated config file before we continue. tied(%configIni)->RewriteConfig or die "Error: Writing config file '$settings{ConfigFileName}' failed! $!\n"; } } else { print "Creating [defaults] section...\n"; # make the [defaults] section appear. $configIni{$profile} = {}; # make sure the section exists. foreach my $arg (keys %defaultSettings) { $configIni{$profile}{$arg} = $defaultSettings{$arg}; print "configIni{$profile}{$arg} = '" . $defaultSettings{$arg} . "'\n" if $settings{Debug}; } # set the config file version $configIni{$profile}{$cfgVersionStr} = $cfgVersion; # write the config file out. tied(%configIni)->RewriteConfig or die "Error: Writing config file '$settings{ConfigFileName}' failed! $!\n"; } } else # create the config file { print "Auto Creating config file $settings{ConfigFileName}...\n"; my $profile = "defaults"; # we have to create the config file and tie to it. tie %configIni, 'Config::IniFiles', () or die "Error: Initializing config file '$settings{ConfigFileName}' failed! $!\n"; # now set the name to work with. tied(%configIni)->SetFileName($settings{ConfigFileName}) or die "Error: Setting config file to '$settings{ConfigFileName}' failed! $!\n"; $configIni{$profile} = {}; # make sure the section exists. foreach my $arg (keys %defaultSettings) { $configIni{$profile}{$arg} = $defaultSettings{$arg}; print "configIni{$profile}{$arg} = '" . $defaultSettings{$arg} . "'\n" if $settings{Debug}; } # set the config file version $configIni{$profile}{$cfgVersionStr} = $cfgVersion; # write the config file out. tied(%configIni)->RewriteConfig or die "Error: Writing config file '$settings{ConfigFileName}' failed! $!\n"; } my $versionStr = "config-editor.pl $version for use with http://ivtv.sf.net/"; my $usageStr = <<"END_OF_USAGE"; $versionStr Usage: config-editor.pl [--help] [--version] [--debug] -h/--help: display this help -v/--version: display the version of this program --debug: turns on debug output Defaults: config file = '$settings{ConfigFileName}' Note: This script relies on Perl Modules: Config::IniFiles and Getopt::Long. END_OF_USAGE # handle user input here my %opts; GetOptions(\%opts, "help|h", "version|v", "debug"); foreach my $option (keys %opts) { my $found = 0; foreach my $mapName (keys %mappings) { if ($option =~ /^($mappings{$mapName})$/) { $settings{$mapName} = $opts{$option}; $found = 1; print "$mapName = '$opts{$option}'\n" if $settings{Debug}; } } if (!$found) { # handle the non-settings cases. if ($option =~ /^(v|version)$/) { print "$versionStr\n"; exit 0; } elsif ($option =~ /^(h|help)$/) { usage(0, ""); } else { usage(1, "-$option is an unknown option!"); } } } my $mw = MainWindow->new; $mw->title("ivtv Config Editor - $version"); my @frame; # create any frames needed $frame[0] = $mw->Frame( -borderwidth => 1, -relief => "ridge" )->pack( -fill => "x" ); $frame[1] = $mw->Frame( -borderwidth => 0 )->pack( -fill => "both", -expand => 1 ); $frame[2] = $frame[1]->Frame( -borderwidth => 0, -label => "Profiles" )->pack( -side => "left", -fill => "y" ); $frame[3] = $frame[1]->Frame( -borderwidth => 0, -label => "Attributes" )->pack( -side => "left", -fill => "y" ); $frame[4] = $frame[1]->Frame( -borderwidth => 0, -label => "Value" )->pack( -side => "left", -fill => "y" ); $frame[5] = $frame[2]->Frame( -borderwidth => 0, )->pack( -side => "top", -fill => "y" ); $frame[6] = $frame[2]->Frame( -borderwidth => 0, )->pack( -side => "bottom", -fill => "x" ); $frame[7] = $frame[3]->Frame( -borderwidth => 0, )->pack( -side => "top", -fill => "y" ); $frame[8] = $frame[3]->Frame( -borderwidth => 0, )->pack( -side => "bottom", -fill => "x" ); $frame[9] = $frame[1]->Frame( -borderwidth => 0, -label => "New Attributes" )->pack( -side => "left", -fill => "y" ); $frame[10] = $mw->Frame( -borderwidth => 0, -label => "Status", -labelPack => [ -side => "left" ] )->pack( -fill => "x"); # create the menu my $menub = $frame[0]->Menubutton(-text => "File", -tearoff => 0)->pack(-side => "left", -anchor => "n"); # create the menu items. $menub->AddItems(["command" => "Save", -command => \&saveFile, -state => "disabled"], "-", ["command" => "Exit", -command => \&doExit]); # verify that the defaults profile is created. If not, create. my $profileName = "defaults"; if (!exists $configIni{$profileName}) { $configIni{$profileName} = {}; # make sure the section exists. foreach my $arg (keys %defaultSettings) { $configIni{$profileName}{$arg} = $defaultSettings{$arg}; print "configIni{$profileName}{$arg} = '" . $defaultSettings{$arg} . "'\n" if $settings{Debug}; } signalSaveNeeded(); } # define the list of available profiles to work with my $profileLB = $frame[5]->Scrolled("Listbox", -selectmode => "single", -scrollbars => "osoe", -exportselection => 0)->pack(-side => "left"); $profileLB->bind("", \&selectProfile); for my $profileName (sort keys %configIni) { $profileLB->insert("end", $profileName); } # create the profile entry field my $valueEntry = $frame[6]->Entry(-textvariable => \$profile)->pack(-side => "top", -fill => "x"); # create the create profile button my $createProfileB = $frame[6]->Button(-text => "Create", -command => \&createProfile)->pack(-side => "left"); # create the delete profile button my $deleteProfileB = $frame[6]->Button(-text => "Delete", -command => \&deleteProfile, -state => "disabled")->pack(-side => "right"); # create the attributes list my $attributeLB = $frame[7]->Scrolled("Listbox", -selectmode => "single", -scrollbars => "osoe", -exportselection => 0)->pack(-side => "left"); $attributeLB->bind("", \&selectAttribute); # create the delete attribute button my $deleteAttributeB = $frame[8]->Button(-text => "Delete", -command => \&deleteAttribute, -state => "disabled")->pack(-side => "right"); # define the value edit field my $valueEntry = $frame[4]->Entry(-textvariable => \$attributeValue)->pack(-side => "top", -fill => "x"); # create the update attribute button my $updateAttributeB = $frame[4]->Button(-text => "Update Attribute", -command => \&updateAttribute, -state => "disabled")->pack(); # create the new attributes list my $newAttributeLB = $frame[9]->Scrolled("Listbox", -selectmode => "single", -scrollbars => "osoe", -exportselection => 0)->pack(-side => "top", -fill => "y"); $newAttributeLB->bind("", \&selectNewAttribute); # populate the new attributes list foreach my $arg (sort keys %defaultSettings) { $newAttributeLB->insert("end", $arg); } # create the status text area my $statusField = $frame[10]->Scrolled("Text", -scrollbars => "osoe", -state => "disabled", -wrap => "word", -height => "5")->pack(-side => "left", -fill => "x"); # create the tags needed for the status area $statusField->tagConfigure("error", -foreground => "red"); MainLoop; sub doExit { if ($changesUnsaved) { # we can't exit unless they want to lose the changes # this code branch should not be reached due to the current implementation of Save/Exit being disabled, etc. } else { exit; } } sub saveFile { # make sure the config version string exists. if (!exists $configIni{defaults}{$cfgVersionStr}) { $configIni{defaults}{$cfgVersionStr} = $cfgVersion; } # write the config file out. tied(%configIni)->RewriteConfig or die "Error: Writing config file '$settings{ConfigFileName}' failed! $!\n"; displayStatus("Saving config file '$settings{ConfigFileName}': ok"); $changesUnsaved = 0; # enable the Exit menu option $menub->entryconfigure(2, -state => "normal"); # disable the Save menu option $menub->entryconfigure(0, -state => "disabled"); } sub signalSaveNeeded { $changesUnsaved = 1; # enable the Save menu option $menub->entryconfigure(0, -state => "normal"); # disable the Exit menu option $menub->entryconfigure(2, -state => "disabled"); } sub selectProfile { my $sel = $profileLB->curselection(); if ($sel ne "") { $profile = $profileLB->get($sel); displayStatus("Selected Profile: " . $profile); # now populate the attributes list box after first clearing it of any old values. $attributeLB->delete(0, 'end'); foreach my $attribute (sort keys %{$configIni{$profile}}) { if ($attribute ne $cfgVersionStr) # don't show the user the config version string. { $attributeLB->insert("end", $attribute); } } # enable the delete profile button $deleteProfileB->configure(-state => "normal"); # disable the update attribute button $updateAttributeB->configure(-state => "disabled"); # reset the attribute value field to nothing. $attributeValue = ""; } } sub createProfile { if ($profile) { if (!exists $configIni{$profile}) { displayStatus("Creating Profile [$profile]..."); $configIni{$profile} = {}; # now display the profiles available. $profileLB->delete(0, 'end'); for my $profileName (sort keys %configIni) { $profileLB->insert("end", $profileName); } signalSaveNeeded(); } else { displayStatus("Profile [$profile] already exists. Not creating."); } } else { displayError("You must specify a profile to create!"); } } sub deleteProfile { if ($profile) { if ($profile ne "defaults") { displayStatus("Deleting Profile [$profile]"); signalSaveNeeded(); delete $configIni{$profile}; $profile = ""; # remove all the profile entries and re-populate $profileLB->delete(0, "end"); for my $profile (sort keys %configIni) { $profileLB->insert("end", $profile); } # remove all attribute entries $attributeLB->delete(0, 'end'); # make sure attribute value is empty $attributeValue = ""; # disable the update attribute button $updateAttributeB->configure(-state => "disabled"); # disable the delete profile button $deleteProfileB->configure(-state => "disabled"); # disable the delete attribute button $deleteAttributeB->configure(-state => "disabled"); } else { displayError("You can not delete the [defaults] profile!"); } } else { displayError("You must select a Profile to delete!"); } } sub selectAttribute { my $sel = $attributeLB->curselection(); if ($sel ne "") { $attribute = $attributeLB->get($sel); $attributeValue = $configIni{$profile}{$attribute}; displayStatus("Selected Attribute: $attribute, value = '$attributeValue'"); # enable the update attribute button $updateAttributeB->configure(-state => "normal"); # enable the delete attribute button $deleteAttributeB->configure(-state => "normal"); } } sub selectNewAttribute { my $sel = $newAttributeLB->curselection(); if ($sel ne "") { $attribute = $newAttributeLB->get($sel); if (!$profile) { displayError("You must select a profile first!"); return; } if (!exists $configIni{$profile}{$attribute} || $configIni{$profile}{$attribute} ne $defaultSettings{$attribute}) { $attributeValue = $defaultSettings{$attribute}; $configIni{$profile}{$attribute} = $attributeValue; signalSaveNeeded(); displayStatus("Created Attribute: $attribute, value = '$attributeValue'"); # remove all attribute entries and re-populate $attributeLB->delete(0, 'end'); foreach my $attribute (sort keys %{$configIni{$profile}}) { $attributeLB->insert("end", $attribute); } # enable the update attribute button $updateAttributeB->configure(-state => "normal"); # enable the delete attribute button $deleteAttributeB->configure(-state => "normal"); # unselect the New Attribute selection $newAttributeLB->selectionClear($sel); } } } sub deleteAttribute { delete $configIni{$profile}{$attribute}; # remove all attribute entries and re-populate $attributeLB->delete(0, 'end'); foreach my $attribute (sort keys %{$configIni{$profile}}) { $attributeLB->insert("end", $attribute); } # make sure attribute value is empty $attributeValue = ""; # disable the update attribute button $updateAttributeB->configure(-state => "disabled"); # disable the delete attribute button $deleteAttributeB->configure(-state => "disabled"); } sub updateAttribute { if ($configIni{$profile}{$attribute} ne $attributeValue) { signalSaveNeeded(); # I really should do some validation... $configIni{$profile}{$attribute} = $attributeValue; # disable the update attribute button $updateAttributeB->configure(-state => "disabled"); } } sub displayStatus { my $output = shift; # enable writing to the status box $statusField->configure(-state => "normal"); $statusField->insert('end lineend', $output . "\n"); # disable writing to the status box $statusField->configure(-state => "disabled"); $statusField->see('end'); } sub displayError { my $output = shift; # enable writing to the status box $statusField->configure(-state => "normal"); $statusField->insert('end', "Error", "error"); # disable writing to the status box $statusField->configure(-state => "disabled"); displayStatus(": $output"); } # usage(returnValue, ErrorString) # returnValue = 1 or 0 # ErrorString = message you want to tell the user, but only if returnValue = 1. sub usage { my $errorCode = shift; my $error = shift; print $usageStr; print "\nError: $error\n" if ($errorCode == 1); print "$error\n" if ($errorCode == 2); exit $errorCode; } ivtv-utils-1.4.1/utils/ivtv-functions.h0000664000076400007640000001356711355717530016657 0ustar andyandy/* Copyright (C) 2004 Chris Kennedy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __IVTV_FUNCTIONS_H #define __IVTV_FUNCTIONS_H #define VIDIOC_STREAMOFF _IOW ('V', 19, int) static inline int ivtv_api_enc_endgop(int ivtvfd, int gop) { /* Send Stop at end of GOP API */ if (ioctl(ivtvfd, IVTV_IOC_S_GOP_END, &gop) < 0) fprintf(stderr, "ioctl: IVTV_IOC_S_GOP_END failed\n"); return 0; } static inline int ivtv_api_enc_stop(int ivtvfd) { int dummy = 0; /* Send Stop Capture API */ if (ioctl(ivtvfd, VIDIOC_STREAMOFF, &dummy) < 0) fprintf(stderr, "ioctl: VIDIOC_STREAMOFF failed\n"); return 0; } static inline int ivtv_api_dec_pause(int ivtvfd, int blackframe) { /* Send Pause Decoding API */ if (ioctl(ivtvfd, IVTV_IOC_PAUSE, &blackframe) < 0) fprintf(stderr, "ioctl: IVTV_IOC_PAUSE failed\n"); return 0; } static inline int ivtv_api_dec_play(int ivtvfd, int firstframe) { /* Send Playback Decoding API */ if (ioctl(ivtvfd, IVTV_IOC_PLAY, &firstframe) < 0) fprintf(stderr, "ioctl: IVTV_IOC_PLAY failed\n"); return 0; } static inline int ivtv_api_dec_start(int ivtvfd) { /* Send Start Decoding API */ struct ivtv_cfg_start_decode sd; sd.gop_offset = 0; sd.muted_audio_frames = 0; if (ioctl(ivtvfd, IVTV_IOC_START_DECODE, &sd) < 0) fprintf(stderr, "ioctl: IVTV_IOC_START_DECODE failed\n"); return 0; } static inline int ivtv_api_dec_splice(int ivtvfd, int offset, int mframes) { /* Send Start Decoding API */ struct ivtv_cfg_start_decode sd; sd.gop_offset = offset; sd.muted_audio_frames = mframes; if (ioctl(ivtvfd, IVTV_IOC_START_DECODE, &sd) < 0) fprintf(stderr, "ioctl: IVTV_IOC_START_DECODE failed\n"); return 0; } static inline int ivtv_api_dec_stop(int ivtvfd, int blackframe, int ptslo, int ptshi) { /* Send Playback Stop Decoding API */ struct ivtv_cfg_stop_decode sd; sd.hide_last = blackframe; sd.pts_stop = ptshi; if (ioctl(ivtvfd, IVTV_IOC_STOP_DECODE, &sd) < 0) fprintf(stderr, "ioctl: IVTV_IOC_STOP_DECODE failed\n"); return 0; } static inline int ivtv_api_dec_flush(int ivtvfd) { /* Send Flush Decoding Buffers API */ if (ioctl(ivtvfd, IVTV_IOC_DEC_FLUSH, 0) < 0) fprintf(stderr, "ioctl: IVTV_IOC_DEC_FLUSH failed\n"); return 0; } static inline int ivtv_api_dec_step(int ivtvfd, int mode) { /* Send Playback Stop Decoding API */ if (ioctl(ivtvfd, IVTV_IOC_DEC_STEP, &mode) < 0) fprintf(stderr, "ioctl: IVTV_IOC_DEC_STEP failed\n"); return 0; } static inline int __ivtv_api_dec_speed(int ivtvfd, int scale, int smooth, int _speed, int direction, int fr_mask, int b_per_gop, int aud_mute, int fr_field, int mute) { struct ivtv_speed speed; speed.scale = scale; speed.smooth = smooth; speed.speed = _speed; speed.direction = direction; speed.fr_mask = fr_mask; speed.b_per_gop = b_per_gop; speed.aud_mute = aud_mute; speed.fr_field = fr_field; speed.mute = mute; if (ioctl(ivtvfd, IVTV_IOC_S_SPEED, &speed) < 0) fprintf(stderr, "ioctl: IVTV_IOC_S_SPEED failed\n"); return 0; } #define FORWARD 0 #define REVERSE 1 #define NORMAL_SPEED 30 static inline int ivtv_api_dec_speed(int ivtvfd, int direction, float fps) { int _speed = (int)fps; int b_per_gop = 1; int aud_mute = 0; int fr_field = 0; int mute = 0; int i_frames = 1; int ip_frames = 3; int ipb_frames = 7; /* Make input sane */ if (direction > 1) direction = 1; else if (direction < 0) direction = 0; if (_speed < FORWARD) _speed = fps = NORMAL_SPEED; if (direction == 0) { /* Forward */ if (fps < NORMAL_SPEED) { _speed = NORMAL_SPEED / fps; __ivtv_api_dec_speed(ivtvfd, _speed, 0, 0, direction, ipb_frames, 0, aud_mute, fr_field, mute); } else if (fps == NORMAL_SPEED) { __ivtv_api_dec_speed(ivtvfd, 0, 0, 0, direction, ipb_frames, 0, aud_mute, fr_field, mute); } else if (fps == (1.5 * NORMAL_SPEED)) { _speed = 1; __ivtv_api_dec_speed(ivtvfd, _speed, 0, 1, direction, ipb_frames, 0, aud_mute, fr_field, mute); } else if (fps > (2 * NORMAL_SPEED)) { __ivtv_api_dec_speed(ivtvfd, 0, 0, 0, direction, i_frames, 0, aud_mute, fr_field, mute); } else { _speed = 2; __ivtv_api_dec_speed(ivtvfd, _speed, 0, 1, direction, ipb_frames, 0, aud_mute, fr_field, mute); } } else { /* Reverse */ if (fps < NORMAL_SPEED) { _speed = NORMAL_SPEED / fps; __ivtv_api_dec_speed(ivtvfd, _speed, 0, 0, direction, ip_frames, b_per_gop, aud_mute, fr_field, mute); } else if (fps == NORMAL_SPEED) { __ivtv_api_dec_speed(ivtvfd, 0, 0, 0, direction, ip_frames, b_per_gop, aud_mute, fr_field, mute); } else if (fps == (1.5 * NORMAL_SPEED)) { /* 1.5x */ _speed = 1; __ivtv_api_dec_speed(ivtvfd, _speed, 0, 1, direction, ip_frames, b_per_gop, aud_mute, fr_field, mute); } else if (fps > (2 * NORMAL_SPEED)) { __ivtv_api_dec_speed(ivtvfd, 0, 0, 0, direction, i_frames, b_per_gop, aud_mute, fr_field, mute); } else { _speed = 2; __ivtv_api_dec_speed(ivtvfd, _speed, 0, 1, direction, ipb_frames, b_per_gop, aud_mute, fr_field, mute); } } return 0; } #endif ivtv-utils-1.4.1/utils/mpeg2structs.h0000664000076400007640000001707511355717530016321 0ustar andyandy/* # # MPEG2 data structures for MPEG2Parser class # # $Id: mpeg2structs.h,v 1.2 2003/11/01 08:35:37 knup Exp $ # # Copyright (C) 2001-2003 Kees Cook # kees@outflux.net, http://outflux.net/ # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # http://www.gnu.org/copyleft/gpl.html # */ #ifndef _MPEG2STRUCTS_H_ #define _MPEG2STRUCTS_H_ #ifndef TRUE # define TRUE 1 #endif #ifndef FALSE # define FALSE 0 #endif /* This problem with these damn compilers is that I can't specify an arbitrary bit layout structure. It always grows to a different size. If someone know how to portably control that problem let me know, and I can stop using bit masks to get at my data. :) */ #define PICTURE_CODING_MASK 0x38 #define PICTURE_CODING_SHIFT 0x03 #define PICTURE_CODING_INTRA 0x01 #define PICTURE_CODING_PREDICTIVE 0x02 #define PICTURE_CODING_BIDIRECTIONAL 0x03 typedef struct { uint8_t start_code[4]; uint8_t bits[2]; /* only stuff I want to get to is picture_coding_type uint16_t temporal_reference:10; uint8_t picture_coding_type:3; */ } picture_header; #define GOP_FLAG_MASK 0x60 #define GOP_FLAG_CLOSED 0x40 #define GOP_FLAG_BROKEN 0x20 typedef struct { uint8_t start_code[4]; uint8_t bits[4]; /* uint32_t time_code:25; uint8_t closed_gop:1; uint8_t broken_link:1; uint8_t unknown:5; */ } group_of_pictures_header; #define ES_TYPE_WEIRD 0 #define ES_TYPE_VIDEO 1 #define ES_TYPE_AUDIO 2 typedef struct { uint8_t start_code[3]; uint8_t stream_id; uint8_t PES_packet_length[2]; } PES_packet_header_t; typedef struct { uint8_t bits[2]; /* uint8_t marker0:2; // 10 uint8_t PES_scrambling_control:2; uint8_t PES_priority:1; uint8_t data_alignment_indicator:1; uint8_t copyright:1; uint8_t original_or_copy:1; uint8_t PTS_DTS_flags:2; uint8_t ESCR_flag:1; uint8_t ES_rate_flag:1; uint8_t DSM_trick_mode_flag:1; uint8_t additional_copy_info_flag:1; uint8_t PES_CRC_flag:1; uint8_t PES_extension_flag:1; */ uint8_t PES_header_data_length; } PES_packet_internals_t; typedef struct { uint8_t marker_bit:1; uint8_t data:7; } PES_packet_additional_copy_info_t; #define GET_BITS(byte,mask,shiftdown) (((byte)&(mask))>>(shiftdown)) #define PPE_PES_private_data_flag(x) GET_BITS(x,0x80,7) #define PPE_pack_header_field_flag(x) GET_BITS(x,0x40,6) #define PPE_program_packet_sequence_counter_flag(x) GET_BITS(x,0x20,5) #define PPE_P_STD_buffer_flag(x) GET_BITS(x,0x10,5) #define PPE_PES_extension_flag_2(x) GET_BITS(x,0x01,0) typedef struct { uint8_t bits[1]; /* uint8_t PES_private_data_flag:1; uint8_t pack_header_field_flag:1; uint8_t program_packet_sequence_counter_flag:1; uint8_t P_STD_buffer_flag:1; uint8_t reserved:3; uint8_t PES_extension_flag_2:1; */ } PES_packet_extension_t; typedef struct { uint8_t marker0:1; uint8_t program_packet_sequence_counter:7; uint8_t marker1:1; uint8_t MPEG1_MPEG2_identifier:1; uint8_t original_stuff_length:6; } PES_packet_extension_program_packet_sequence_counter_t; #define PES_TYPE_picture_start 0x00 // slice start: 0x01 - 0xAF // reserved: 0xB0 - 0xB1 #define PES_TYPE_user_data_start 0xB2 #define PES_TYPE_sequence_header 0xB3 #define PES_TYPE_sequence_error 0xB4 #define PES_TYPE_extension_start 0xB5 // reserved: 0xB6 #define PES_TYPE_sequence_end 0xB7 #define PES_TYPE_group_start 0xB8 #define PES_TYPE_program_end 0xB9 #define PES_TYPE_pack_start 0xBA #define PES_TYPE_system_header 0xBB #define PES_TYPE_program_stream_map 0xBC /* PES simple */ #define PES_TYPE_private_stream_1 0xBD /* PES complex */ #define PES_TYPE_padding_stream 0xBE /* PES simple */ #define PES_TYPE_private_stream_2 0xBF /* PES simple */ #define PES_TYPE_ECM_stream 0xF0 /* PES simple */ #define PES_TYPE_EMM_stream 0xF1 /* PES simple */ #define PES_TYPE_DSMCC_stream 0xF2 /* PES simple */ #define PES_TYPE_ISO_13522 0xF3 /* PES complex */ #define PES_TYPE_H2221A 0xF4 /* PES complex */ #define PES_TYPE_H2221B 0xF5 /* PES complex */ #define PES_TYPE_H2221C 0xF6 /* PES complex */ #define PES_TYPE_H2221D 0xF7 /* PES complex */ #define PES_TYPE_H2221E 0xF8 /* PES simple */ #define PES_TYPE_ancillary_stream 0xF9 /* PES complex */ // reserved: 0xFA - 0xFE /* PES complex */ #define PES_TYPE_program_stream_directory 0xFF /* PES simple */ #define PES_TYPE_audio 0xC0 /* PES complex */ #define PES_TYPE_MASK_audio 0xE0 #define PES_TYPE_video 0xE0 /* PES complex */ #define PES_TYPE_MASK_video 0xF0 // xxxxx xxxxx // subtitles: 0x20..0x3F 00100000..00111111 #define DVD_AUDIO_TYPE_sub 0x20 #define DVD_AUDIO_TYPE_MASK_sub 0xE0 // xxxxx xxxxx // AC3: 0x80..0x9F 10000000..10011111 #define DVD_AUDIO_TYPE_ac3 0x80 #define DVD_AUDIO_TYPE_MASK_ac3 0xE0 // xxxxx xxxxx // PCM: 0xA0..0xBF 10100000..10111111 #define DVD_AUDIO_TYPE_pcm 0xA0 #define DVD_AUDIO_TYPE_MASK_pcm 0xE0 typedef struct { uint8_t start_code[4]; uint16_t header_length; uint8_t bits[6]; /* uint32_t marker0:1; // 1 uint32_t rate_bound:22; uint32_t marker1:1; // 1 uint32_t audio_bound:6; uint32_t fixed_flag:1; uint32_t CSPS_flag:1; uint8_t system_audio_lock_flag:1; uint8_t system_video_lock_flag:1; uint8_t marker2:1; // 1 uint8_t video_bound:5; uint8_t packet_rate_restriction_flag:1; uint8_t reserved:7; */ } system_header_t; typedef struct { uint8_t stream_id; // 1011 1000: P_STD map to all audio streams // 1011 1001: P_STD map to all video streams // otherwise, must be >= 1011 1100 // uint8_t bits[2]; /* uint16_t marker0:2; // 11 uint16_t P_STD_buffer_bound_scale:1; uint16_t P_STD_buffer_size_bound:13; */ } stream_id_t; typedef struct { uint8_t start_code[4]; /* uint32_t marker0:2; // 01 uint32_t system_clock_reference_base_hi:3; uint32_t marker1:1; // 1 uint32_t system_clock_reference_base_mid:15; uint32_t marker2:1; // 1 uint32_t system_clock_reference_base_low:15; uint16_t marker3:1; // 1 uint16_t system_clock_reference_extension:9; uint16_t marker4:1; // 1 uint32_t program_mux_rate:22; uint32_t marker5:1; // 1 uint32_t marker6:1; // 1 uint8_t reserved:5; uint8_t pack_stuffing_length:3; */ uint8_t bits[10]; } pack_header_t; #endif // _MPEG2STRUCTS_H_ /* vi:set ai ts=4 sw=4 expandtab: */ ivtv-utils-1.4.1/utils/linux/0000775000076400007640000000000011355717714014637 5ustar andyandyivtv-utils-1.4.1/utils/linux/ivtv.h0000664000076400007640000000511111355717530015772 0ustar andyandy/* Public ivtv API header Copyright (C) 2003-2004 Kevin Thayer Copyright (C) 2004-2007 Hans Verkuil This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __LINUX_IVTV_H__ #define __LINUX_IVTV_H__ #include #include /* ivtv knows several distinct output modes: MPEG streaming, YUV streaming, YUV updates through user DMA and the passthrough mode. In order to clearly tell the driver that we are in user DMA YUV mode you need to call IVTV_IOC_DMA_FRAME with y_source == NULL first (althrough if you don't then the first time DMA_FRAME is called the mode switch is done automatically). When you close the file handle the user DMA mode is exited again. While in one mode, you cannot use another mode (EBUSY is returned). All this means that if you want to change the YUV interlacing for the user DMA YUV mode you first need to do call IVTV_IOC_DMA_FRAME with y_source == NULL before you can set the correct format using VIDIOC_S_FMT. Eventually all this should be replaced with a proper V4L2 API, but for now we have to do it this way. */ struct ivtv_dma_frame { enum v4l2_buf_type type; /* V4L2_BUF_TYPE_VIDEO_OUTPUT */ __u32 pixelformat; /* 0 == same as destination */ void *y_source; /* if NULL and type == V4L2_BUF_TYPE_VIDEO_OUTPUT, then just switch to user DMA YUV output mode */ void *uv_source; /* Unused for RGB pixelformats */ struct v4l2_rect src; struct v4l2_rect dst; __u32 src_width; __u32 src_height; }; #define IVTV_IOC_DMA_FRAME _IOW ('V', BASE_VIDIOC_PRIVATE+0, struct ivtv_dma_frame) /* These are the VBI types as they appear in the embedded VBI private packets. */ #define IVTV_SLICED_TYPE_TELETEXT_B (1) #define IVTV_SLICED_TYPE_CAPTION_525 (4) #define IVTV_SLICED_TYPE_WSS_625 (5) #define IVTV_SLICED_TYPE_VPS (7) #endif /* _LINUX_IVTV_H */ ivtv-utils-1.4.1/utils/linux/ivtvfb.h0000664000076400007640000000225311355717530016306 0ustar andyandy/* On Screen Display cx23415 Framebuffer driver Copyright (C) 2006, 2007 Ian Armstrong This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __LINUX_IVTVFB_H__ #define __LINUX_IVTVFB_H__ #include /* Framebuffer external API */ struct ivtvfb_dma_frame { void *source; unsigned long dest_offset; int count; }; #define IVTVFB_IOC_DMA_FRAME _IOW('V', BASE_VIDIOC_PRIVATE+0, struct ivtvfb_dma_frame) #define FBIO_WAITFORVSYNC _IOW('F', 0x20, u_int32_t) #endif ivtv-utils-1.4.1/utils/linux/videodev2.h0000664000076400007640000015622211355717530016703 0ustar andyandy/* * Video for Linux Two header file * * Copyright (C) 1999-2007 the contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * Alternatively you can redistribute this file under the terms of the * BSD license as stated below: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * 3. The names of its contributors may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Header file for v4l or V4L2 drivers and applications * with public API. * All kernel-specific stuff were moved to media/v4l2-dev.h, so * no #if __KERNEL tests are allowed here * * See http://linuxtv.org for more info * * Author: Bill Dirks * Justin Schoeman * Hans Verkuil * et al. */ #ifndef __LINUX_VIDEODEV2_H #define __LINUX_VIDEODEV2_H #include #include #include /* * Common stuff for both V4L1 and V4L2 * Moved from videodev.h */ #define VIDEO_MAX_FRAME 32 #ifndef __KERNEL__ /* These defines are V4L1 specific and should not be used with the V4L2 API! They will be removed from this header in the future. */ #define VID_TYPE_CAPTURE 1 /* Can capture */ #define VID_TYPE_TUNER 2 /* Can tune */ #define VID_TYPE_TELETEXT 4 /* Does teletext */ #define VID_TYPE_OVERLAY 8 /* Overlay onto frame buffer */ #define VID_TYPE_CHROMAKEY 16 /* Overlay by chromakey */ #define VID_TYPE_CLIPPING 32 /* Can clip */ #define VID_TYPE_FRAMERAM 64 /* Uses the frame buffer memory */ #define VID_TYPE_SCALES 128 /* Scalable */ #define VID_TYPE_MONOCHROME 256 /* Monochrome only */ #define VID_TYPE_SUBCAPTURE 512 /* Can capture subareas of the image */ #define VID_TYPE_MPEG_DECODER 1024 /* Can decode MPEG streams */ #define VID_TYPE_MPEG_ENCODER 2048 /* Can encode MPEG streams */ #define VID_TYPE_MJPEG_DECODER 4096 /* Can decode MJPEG streams */ #define VID_TYPE_MJPEG_ENCODER 8192 /* Can encode MJPEG streams */ #endif /* * M I S C E L L A N E O U S */ /* Four-character-code (FOURCC) */ #define v4l2_fourcc(a, b, c, d)\ ((__u32)(a) | ((__u32)(b) << 8) | ((__u32)(c) << 16) | ((__u32)(d) << 24)) /* * E N U M S */ enum v4l2_field { V4L2_FIELD_ANY = 0, /* driver can choose from none, top, bottom, interlaced depending on whatever it thinks is approximate ... */ V4L2_FIELD_NONE = 1, /* this device has no fields ... */ V4L2_FIELD_TOP = 2, /* top field only */ V4L2_FIELD_BOTTOM = 3, /* bottom field only */ V4L2_FIELD_INTERLACED = 4, /* both fields interlaced */ V4L2_FIELD_SEQ_TB = 5, /* both fields sequential into one buffer, top-bottom order */ V4L2_FIELD_SEQ_BT = 6, /* same as above + bottom-top order */ V4L2_FIELD_ALTERNATE = 7, /* both fields alternating into separate buffers */ V4L2_FIELD_INTERLACED_TB = 8, /* both fields interlaced, top field first and the top field is transmitted first */ V4L2_FIELD_INTERLACED_BT = 9, /* both fields interlaced, top field first and the bottom field is transmitted first */ }; #define V4L2_FIELD_HAS_TOP(field) \ ((field) == V4L2_FIELD_TOP ||\ (field) == V4L2_FIELD_INTERLACED ||\ (field) == V4L2_FIELD_INTERLACED_TB ||\ (field) == V4L2_FIELD_INTERLACED_BT ||\ (field) == V4L2_FIELD_SEQ_TB ||\ (field) == V4L2_FIELD_SEQ_BT) #define V4L2_FIELD_HAS_BOTTOM(field) \ ((field) == V4L2_FIELD_BOTTOM ||\ (field) == V4L2_FIELD_INTERLACED ||\ (field) == V4L2_FIELD_INTERLACED_TB ||\ (field) == V4L2_FIELD_INTERLACED_BT ||\ (field) == V4L2_FIELD_SEQ_TB ||\ (field) == V4L2_FIELD_SEQ_BT) #define V4L2_FIELD_HAS_BOTH(field) \ ((field) == V4L2_FIELD_INTERLACED ||\ (field) == V4L2_FIELD_INTERLACED_TB ||\ (field) == V4L2_FIELD_INTERLACED_BT ||\ (field) == V4L2_FIELD_SEQ_TB ||\ (field) == V4L2_FIELD_SEQ_BT) enum v4l2_buf_type { V4L2_BUF_TYPE_VIDEO_CAPTURE = 1, V4L2_BUF_TYPE_VIDEO_OUTPUT = 2, V4L2_BUF_TYPE_VIDEO_OVERLAY = 3, V4L2_BUF_TYPE_VBI_CAPTURE = 4, V4L2_BUF_TYPE_VBI_OUTPUT = 5, V4L2_BUF_TYPE_SLICED_VBI_CAPTURE = 6, V4L2_BUF_TYPE_SLICED_VBI_OUTPUT = 7, #if 1 /*KEEP*/ /* Experimental */ V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY = 8, #endif V4L2_BUF_TYPE_PRIVATE = 0x80, }; enum v4l2_ctrl_type { V4L2_CTRL_TYPE_INTEGER = 1, V4L2_CTRL_TYPE_BOOLEAN = 2, V4L2_CTRL_TYPE_MENU = 3, V4L2_CTRL_TYPE_BUTTON = 4, V4L2_CTRL_TYPE_INTEGER64 = 5, V4L2_CTRL_TYPE_CTRL_CLASS = 6, }; enum v4l2_tuner_type { V4L2_TUNER_RADIO = 1, V4L2_TUNER_ANALOG_TV = 2, V4L2_TUNER_DIGITAL_TV = 3, }; enum v4l2_memory { V4L2_MEMORY_MMAP = 1, V4L2_MEMORY_USERPTR = 2, V4L2_MEMORY_OVERLAY = 3, }; /* see also http://vektor.theorem.ca/graphics/ycbcr/ */ enum v4l2_colorspace { /* ITU-R 601 -- broadcast NTSC/PAL */ V4L2_COLORSPACE_SMPTE170M = 1, /* 1125-Line (US) HDTV */ V4L2_COLORSPACE_SMPTE240M = 2, /* HD and modern captures. */ V4L2_COLORSPACE_REC709 = 3, /* broken BT878 extents (601, luma range 16-253 instead of 16-235) */ V4L2_COLORSPACE_BT878 = 4, /* These should be useful. Assume 601 extents. */ V4L2_COLORSPACE_470_SYSTEM_M = 5, V4L2_COLORSPACE_470_SYSTEM_BG = 6, /* I know there will be cameras that send this. So, this is * unspecified chromaticities and full 0-255 on each of the * Y'CbCr components */ V4L2_COLORSPACE_JPEG = 7, /* For RGB colourspaces, this is probably a good start. */ V4L2_COLORSPACE_SRGB = 8, }; enum v4l2_priority { V4L2_PRIORITY_UNSET = 0, /* not initialized */ V4L2_PRIORITY_BACKGROUND = 1, V4L2_PRIORITY_INTERACTIVE = 2, V4L2_PRIORITY_RECORD = 3, V4L2_PRIORITY_DEFAULT = V4L2_PRIORITY_INTERACTIVE, }; struct v4l2_rect { __s32 left; __s32 top; __s32 width; __s32 height; }; struct v4l2_fract { __u32 numerator; __u32 denominator; }; /* * D R I V E R C A P A B I L I T I E S */ struct v4l2_capability { __u8 driver[16]; /* i.e. "bttv" */ __u8 card[32]; /* i.e. "Hauppauge WinTV" */ __u8 bus_info[32]; /* "PCI:" + pci_name(pci_dev) */ __u32 version; /* should use KERNEL_VERSION() */ __u32 capabilities; /* Device capabilities */ __u32 reserved[4]; }; /* Values for 'capabilities' field */ #define V4L2_CAP_VIDEO_CAPTURE 0x00000001 /* Is a video capture device */ #define V4L2_CAP_VIDEO_OUTPUT 0x00000002 /* Is a video output device */ #define V4L2_CAP_VIDEO_OVERLAY 0x00000004 /* Can do video overlay */ #define V4L2_CAP_VBI_CAPTURE 0x00000010 /* Is a raw VBI capture device */ #define V4L2_CAP_VBI_OUTPUT 0x00000020 /* Is a raw VBI output device */ #define V4L2_CAP_SLICED_VBI_CAPTURE 0x00000040 /* Is a sliced VBI capture device */ #define V4L2_CAP_SLICED_VBI_OUTPUT 0x00000080 /* Is a sliced VBI output device */ #define V4L2_CAP_RDS_CAPTURE 0x00000100 /* RDS data capture */ #define V4L2_CAP_VIDEO_OUTPUT_OVERLAY 0x00000200 /* Can do video output overlay */ #define V4L2_CAP_HW_FREQ_SEEK 0x00000400 /* Can do hardware frequency seek */ #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 */ #define V4L2_CAP_STREAMING 0x04000000 /* streaming I/O ioctls */ /* * V I D E O I M A G E F O R M A T */ struct v4l2_pix_format { __u32 width; __u32 height; __u32 pixelformat; enum v4l2_field field; __u32 bytesperline; /* for padding, zero if unused */ __u32 sizeimage; enum v4l2_colorspace colorspace; __u32 priv; /* private data, depends on pixelformat */ }; /* Pixel format FOURCC depth Description */ #define V4L2_PIX_FMT_RGB332 v4l2_fourcc('R', 'G', 'B', '1') /* 8 RGB-3-3-2 */ #define V4L2_PIX_FMT_RGB444 v4l2_fourcc('R', '4', '4', '4') /* 16 xxxxrrrr ggggbbbb */ #define V4L2_PIX_FMT_RGB555 v4l2_fourcc('R', 'G', 'B', 'O') /* 16 RGB-5-5-5 */ #define V4L2_PIX_FMT_RGB565 v4l2_fourcc('R', 'G', 'B', 'P') /* 16 RGB-5-6-5 */ #define V4L2_PIX_FMT_RGB555X v4l2_fourcc('R', 'G', 'B', 'Q') /* 16 RGB-5-5-5 BE */ #define V4L2_PIX_FMT_RGB565X v4l2_fourcc('R', 'G', 'B', 'R') /* 16 RGB-5-6-5 BE */ #define V4L2_PIX_FMT_BGR24 v4l2_fourcc('B', 'G', 'R', '3') /* 24 BGR-8-8-8 */ #define V4L2_PIX_FMT_RGB24 v4l2_fourcc('R', 'G', 'B', '3') /* 24 RGB-8-8-8 */ #define V4L2_PIX_FMT_BGR32 v4l2_fourcc('B', 'G', 'R', '4') /* 32 BGR-8-8-8-8 */ #define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R', 'G', 'B', '4') /* 32 RGB-8-8-8-8 */ #define V4L2_PIX_FMT_GREY v4l2_fourcc('G', 'R', 'E', 'Y') /* 8 Greyscale */ #define V4L2_PIX_FMT_Y16 v4l2_fourcc('Y', '1', '6', ' ') /* 16 Greyscale */ #define V4L2_PIX_FMT_PAL8 v4l2_fourcc('P', 'A', 'L', '8') /* 8 8-bit palette */ #define V4L2_PIX_FMT_YVU410 v4l2_fourcc('Y', 'V', 'U', '9') /* 9 YVU 4:1:0 */ #define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y', 'V', '1', '2') /* 12 YVU 4:2:0 */ #define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y', 'U', 'Y', 'V') /* 16 YUV 4:2:2 */ #define V4L2_PIX_FMT_UYVY v4l2_fourcc('U', 'Y', 'V', 'Y') /* 16 YUV 4:2:2 */ #define V4L2_PIX_FMT_VYUY v4l2_fourcc('V', 'Y', 'U', 'Y') /* 16 YUV 4:2:2 */ #define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4', '2', '2', 'P') /* 16 YVU422 planar */ #define V4L2_PIX_FMT_YUV411P v4l2_fourcc('4', '1', '1', 'P') /* 16 YVU411 planar */ #define V4L2_PIX_FMT_Y41P v4l2_fourcc('Y', '4', '1', 'P') /* 12 YUV 4:1:1 */ #define V4L2_PIX_FMT_YUV444 v4l2_fourcc('Y', '4', '4', '4') /* 16 xxxxyyyy uuuuvvvv */ #define V4L2_PIX_FMT_YUV555 v4l2_fourcc('Y', 'U', 'V', 'O') /* 16 YUV-5-5-5 */ #define V4L2_PIX_FMT_YUV565 v4l2_fourcc('Y', 'U', 'V', 'P') /* 16 YUV-5-6-5 */ #define V4L2_PIX_FMT_YUV32 v4l2_fourcc('Y', 'U', 'V', '4') /* 32 YUV-8-8-8-8 */ /* two planes -- one Y, one Cr + Cb interleaved */ #define V4L2_PIX_FMT_NV12 v4l2_fourcc('N', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 */ #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 */ /* The following formats are not defined in the V4L2 specification */ #define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y', 'U', 'V', '9') /* 9 YUV 4:1:0 */ #define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y', 'U', '1', '2') /* 12 YUV 4:2:0 */ #define V4L2_PIX_FMT_YYUV v4l2_fourcc('Y', 'Y', 'U', 'V') /* 16 YUV 4:2:2 */ #define V4L2_PIX_FMT_HI240 v4l2_fourcc('H', 'I', '2', '4') /* 8 8-bit color */ #define V4L2_PIX_FMT_HM12 v4l2_fourcc('H', 'M', '1', '2') /* 8 YUV 4:2:0 16x16 macroblocks */ /* see http://www.siliconimaging.com/RGB%20Bayer.htm */ #define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1') /* 8 BGBG.. GRGR.. */ #define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G') /* 8 GBGB.. RGRG.. */ /* * 10bit raw bayer, expanded to 16 bits * xxxxrrrrrrrrrrxxxxgggggggggg xxxxggggggggggxxxxbbbbbbbbbb... */ #define V4L2_PIX_FMT_SGRBG10 v4l2_fourcc('B', 'A', '1', '0') /* 10bit raw bayer DPCM compressed to 8 bits */ #define V4L2_PIX_FMT_SGRBG10DPCM8 v4l2_fourcc('B', 'D', '1', '0') #define V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B', 'Y', 'R', '2') /* 16 BGBG.. GRGR.. */ /* compressed formats */ #define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M', 'J', 'P', 'G') /* Motion-JPEG */ #define V4L2_PIX_FMT_JPEG v4l2_fourcc('J', 'P', 'E', 'G') /* JFIF JPEG */ #define V4L2_PIX_FMT_DV v4l2_fourcc('d', 'v', 's', 'd') /* 1394 */ #define V4L2_PIX_FMT_MPEG v4l2_fourcc('M', 'P', 'E', 'G') /* MPEG-1/2/4 */ /* Vendor-specific formats */ #define V4L2_PIX_FMT_WNVA v4l2_fourcc('W', 'N', 'V', 'A') /* Winnov hw compress */ #define V4L2_PIX_FMT_SN9C10X v4l2_fourcc('S', '9', '1', '0') /* SN9C10x compression */ #define V4L2_PIX_FMT_PWC1 v4l2_fourcc('P', 'W', 'C', '1') /* pwc older webcam */ #define V4L2_PIX_FMT_PWC2 v4l2_fourcc('P', 'W', 'C', '2') /* pwc newer webcam */ #define V4L2_PIX_FMT_ET61X251 v4l2_fourcc('E', '6', '2', '5') /* ET61X251 compression */ #define V4L2_PIX_FMT_SPCA501 v4l2_fourcc('S', '5', '0', '1') /* YUYV per line */ #define V4L2_PIX_FMT_SPCA505 v4l2_fourcc('S', '5', '0', '5') /* YYUV per line */ #define V4L2_PIX_FMT_SPCA508 v4l2_fourcc('S', '5', '0', '8') /* YUVY per line */ #define V4L2_PIX_FMT_SPCA561 v4l2_fourcc('S', '5', '6', '1') /* compressed GBRG bayer */ #define V4L2_PIX_FMT_PAC207 v4l2_fourcc('P', '2', '0', '7') /* compressed BGGR bayer */ #define V4L2_PIX_FMT_MR97310A v4l2_fourcc('M', '3', '1', '0') /* compressed BGGR bayer */ #define V4L2_PIX_FMT_SQ905C v4l2_fourcc('9', '0', '5', 'C') /* compressed RGGB bayer */ #define V4L2_PIX_FMT_PJPG v4l2_fourcc('P', 'J', 'P', 'G') /* Pixart 73xx JPEG */ #define V4L2_PIX_FMT_YVYU v4l2_fourcc('Y', 'V', 'Y', 'U') /* 16 YVU 4:2:2 */ /* * F O R M A T E N U M E R A T I O N */ struct v4l2_fmtdesc { __u32 index; /* Format number */ enum v4l2_buf_type type; /* buffer type */ __u32 flags; __u8 description[32]; /* Description string */ __u32 pixelformat; /* Format fourcc */ __u32 reserved[4]; }; #define V4L2_FMT_FLAG_COMPRESSED 0x0001 #if 1 /*KEEP*/ /* Experimental Frame Size and frame rate enumeration */ /* * F R A M E S I Z E E N U M E R A T I O N */ enum v4l2_frmsizetypes { V4L2_FRMSIZE_TYPE_DISCRETE = 1, V4L2_FRMSIZE_TYPE_CONTINUOUS = 2, V4L2_FRMSIZE_TYPE_STEPWISE = 3, }; struct v4l2_frmsize_discrete { __u32 width; /* Frame width [pixel] */ __u32 height; /* Frame height [pixel] */ }; struct v4l2_frmsize_stepwise { __u32 min_width; /* Minimum frame width [pixel] */ __u32 max_width; /* Maximum frame width [pixel] */ __u32 step_width; /* Frame width step size [pixel] */ __u32 min_height; /* Minimum frame height [pixel] */ __u32 max_height; /* Maximum frame height [pixel] */ __u32 step_height; /* Frame height step size [pixel] */ }; struct v4l2_frmsizeenum { __u32 index; /* Frame size number */ __u32 pixel_format; /* Pixel format */ __u32 type; /* Frame size type the device supports. */ union { /* Frame size */ struct v4l2_frmsize_discrete discrete; struct v4l2_frmsize_stepwise stepwise; }; __u32 reserved[2]; /* Reserved space for future use */ }; /* * F R A M E R A T E E N U M E R A T I O N */ enum v4l2_frmivaltypes { V4L2_FRMIVAL_TYPE_DISCRETE = 1, V4L2_FRMIVAL_TYPE_CONTINUOUS = 2, V4L2_FRMIVAL_TYPE_STEPWISE = 3, }; struct v4l2_frmival_stepwise { struct v4l2_fract min; /* Minimum frame interval [s] */ struct v4l2_fract max; /* Maximum frame interval [s] */ struct v4l2_fract step; /* Frame interval step size [s] */ }; struct v4l2_frmivalenum { __u32 index; /* Frame format index */ __u32 pixel_format; /* Pixel format */ __u32 width; /* Frame width */ __u32 height; /* Frame height */ __u32 type; /* Frame interval type the device supports. */ union { /* Frame interval */ struct v4l2_fract discrete; struct v4l2_frmival_stepwise stepwise; }; __u32 reserved[2]; /* Reserved space for future use */ }; #endif /* * T I M E C O D E */ struct v4l2_timecode { __u32 type; __u32 flags; __u8 frames; __u8 seconds; __u8 minutes; __u8 hours; __u8 userbits[4]; }; /* Type */ #define V4L2_TC_TYPE_24FPS 1 #define V4L2_TC_TYPE_25FPS 2 #define V4L2_TC_TYPE_30FPS 3 #define V4L2_TC_TYPE_50FPS 4 #define V4L2_TC_TYPE_60FPS 5 /* Flags */ #define V4L2_TC_FLAG_DROPFRAME 0x0001 /* "drop-frame" mode */ #define V4L2_TC_FLAG_COLORFRAME 0x0002 #define V4L2_TC_USERBITS_field 0x000C #define V4L2_TC_USERBITS_USERDEFINED 0x0000 #define V4L2_TC_USERBITS_8BITCHARS 0x0008 /* The above is based on SMPTE timecodes */ struct v4l2_jpegcompression { int quality; int APPn; /* Number of APP segment to be written, * must be 0..15 */ int APP_len; /* Length of data in JPEG APPn segment */ char APP_data[60]; /* Data in the JPEG APPn segment. */ int COM_len; /* Length of data in JPEG COM segment */ char COM_data[60]; /* Data in JPEG COM segment */ __u32 jpeg_markers; /* Which markers should go into the JPEG * output. Unless you exactly know what * you do, leave them untouched. * Inluding less markers will make the * resulting code smaller, but there will * be fewer aplications which can read it. * The presence of the APP and COM marker * is influenced by APP_len and COM_len * ONLY, not by this property! */ #define V4L2_JPEG_MARKER_DHT (1<<3) /* Define Huffman Tables */ #define V4L2_JPEG_MARKER_DQT (1<<4) /* Define Quantization Tables */ #define V4L2_JPEG_MARKER_DRI (1<<5) /* Define Restart Interval */ #define V4L2_JPEG_MARKER_COM (1<<6) /* Comment segment */ #define V4L2_JPEG_MARKER_APP (1<<7) /* App segment, driver will * allways use APP0 */ }; /* * M E M O R Y - M A P P I N G B U F F E R S */ struct v4l2_requestbuffers { __u32 count; enum v4l2_buf_type type; enum v4l2_memory memory; __u32 reserved[2]; }; struct v4l2_buffer { __u32 index; enum v4l2_buf_type type; __u32 bytesused; __u32 flags; enum v4l2_field field; struct timeval timestamp; struct v4l2_timecode timecode; __u32 sequence; /* memory location */ enum v4l2_memory memory; union { __u32 offset; unsigned long userptr; } m; __u32 length; __u32 input; __u32 reserved; }; /* Flags for 'flags' field */ #define V4L2_BUF_FLAG_MAPPED 0x0001 /* Buffer is mapped (flag) */ #define V4L2_BUF_FLAG_QUEUED 0x0002 /* Buffer is queued for processing */ #define V4L2_BUF_FLAG_DONE 0x0004 /* Buffer is ready */ #define V4L2_BUF_FLAG_KEYFRAME 0x0008 /* Image is a keyframe (I-frame) */ #define V4L2_BUF_FLAG_PFRAME 0x0010 /* Image is a P-frame */ #define V4L2_BUF_FLAG_BFRAME 0x0020 /* Image is a B-frame */ #define V4L2_BUF_FLAG_TIMECODE 0x0100 /* timecode field is valid */ #define V4L2_BUF_FLAG_INPUT 0x0200 /* input field is valid */ /* * O V E R L A Y P R E V I E W */ struct v4l2_framebuffer { __u32 capability; __u32 flags; /* 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; }; /* Flags for the 'capability' field. Read only */ #define V4L2_FBUF_CAP_EXTERNOVERLAY 0x0001 #define V4L2_FBUF_CAP_CHROMAKEY 0x0002 #define V4L2_FBUF_CAP_LIST_CLIPPING 0x0004 #define V4L2_FBUF_CAP_BITMAP_CLIPPING 0x0008 #define V4L2_FBUF_CAP_LOCAL_ALPHA 0x0010 #define V4L2_FBUF_CAP_GLOBAL_ALPHA 0x0020 #define V4L2_FBUF_CAP_LOCAL_INV_ALPHA 0x0040 /* Flags for the 'flags' field. */ #define V4L2_FBUF_FLAG_PRIMARY 0x0001 #define V4L2_FBUF_FLAG_OVERLAY 0x0002 #define V4L2_FBUF_FLAG_CHROMAKEY 0x0004 #define V4L2_FBUF_FLAG_LOCAL_ALPHA 0x0008 #define V4L2_FBUF_FLAG_GLOBAL_ALPHA 0x0010 #define V4L2_FBUF_FLAG_LOCAL_INV_ALPHA 0x0020 struct v4l2_clip { struct v4l2_rect c; struct v4l2_clip *next; }; struct v4l2_window { struct v4l2_rect w; enum v4l2_field field; __u32 chromakey; struct v4l2_clip *clips; __u32 clipcount; void *bitmap; __u8 global_alpha; }; /* * C A P T U R E P A R A M E T E R S */ struct v4l2_captureparm { __u32 capability; /* Supported modes */ __u32 capturemode; /* Current mode */ struct v4l2_fract timeperframe; /* Time per frame in .1us units */ __u32 extendedmode; /* Driver-specific extensions */ __u32 readbuffers; /* # of buffers for read */ __u32 reserved[4]; }; /* Flags for 'capability' and 'capturemode' fields */ #define V4L2_MODE_HIGHQUALITY 0x0001 /* High quality imaging mode */ #define V4L2_CAP_TIMEPERFRAME 0x1000 /* timeperframe field is supported */ struct v4l2_outputparm { __u32 capability; /* Supported modes */ __u32 outputmode; /* Current mode */ struct v4l2_fract timeperframe; /* Time per frame in seconds */ __u32 extendedmode; /* Driver-specific extensions */ __u32 writebuffers; /* # of buffers for write */ __u32 reserved[4]; }; /* * I N P U T I M A G E C R O P P I N G */ struct v4l2_cropcap { enum v4l2_buf_type type; struct v4l2_rect bounds; struct v4l2_rect defrect; struct v4l2_fract pixelaspect; }; struct v4l2_crop { enum v4l2_buf_type type; struct v4l2_rect c; }; /* * A N A L O G V I D E O S T A N D A R D */ typedef __u64 v4l2_std_id; /* one bit for each */ #define V4L2_STD_PAL_B ((v4l2_std_id)0x00000001) #define V4L2_STD_PAL_B1 ((v4l2_std_id)0x00000002) #define V4L2_STD_PAL_G ((v4l2_std_id)0x00000004) #define V4L2_STD_PAL_H ((v4l2_std_id)0x00000008) #define V4L2_STD_PAL_I ((v4l2_std_id)0x00000010) #define V4L2_STD_PAL_D ((v4l2_std_id)0x00000020) #define V4L2_STD_PAL_D1 ((v4l2_std_id)0x00000040) #define V4L2_STD_PAL_K ((v4l2_std_id)0x00000080) #define V4L2_STD_PAL_M ((v4l2_std_id)0x00000100) #define V4L2_STD_PAL_N ((v4l2_std_id)0x00000200) #define V4L2_STD_PAL_Nc ((v4l2_std_id)0x00000400) #define V4L2_STD_PAL_60 ((v4l2_std_id)0x00000800) #define V4L2_STD_NTSC_M ((v4l2_std_id)0x00001000) #define V4L2_STD_NTSC_M_JP ((v4l2_std_id)0x00002000) #define V4L2_STD_NTSC_443 ((v4l2_std_id)0x00004000) #define V4L2_STD_NTSC_M_KR ((v4l2_std_id)0x00008000) #define V4L2_STD_SECAM_B ((v4l2_std_id)0x00010000) #define V4L2_STD_SECAM_D ((v4l2_std_id)0x00020000) #define V4L2_STD_SECAM_G ((v4l2_std_id)0x00040000) #define V4L2_STD_SECAM_H ((v4l2_std_id)0x00080000) #define V4L2_STD_SECAM_K ((v4l2_std_id)0x00100000) #define V4L2_STD_SECAM_K1 ((v4l2_std_id)0x00200000) #define V4L2_STD_SECAM_L ((v4l2_std_id)0x00400000) #define V4L2_STD_SECAM_LC ((v4l2_std_id)0x00800000) /* ATSC/HDTV */ #define V4L2_STD_ATSC_8_VSB ((v4l2_std_id)0x01000000) #define V4L2_STD_ATSC_16_VSB ((v4l2_std_id)0x02000000) /* FIXME: Although std_id is 64 bits, there is an issue on PPC32 architecture that makes switch(__u64) to break. So, there's a hack on v4l2-common.c rounding this value to 32 bits. As, currently, the max value is for V4L2_STD_ATSC_16_VSB (30 bits wide), it should work fine. However, if needed to add more than two standards, v4l2-common.c should be fixed. */ /* some merged standards */ #define V4L2_STD_MN (V4L2_STD_PAL_M|V4L2_STD_PAL_N|V4L2_STD_PAL_Nc|V4L2_STD_NTSC) #define V4L2_STD_B (V4L2_STD_PAL_B|V4L2_STD_PAL_B1|V4L2_STD_SECAM_B) #define V4L2_STD_GH (V4L2_STD_PAL_G|V4L2_STD_PAL_H|V4L2_STD_SECAM_G|V4L2_STD_SECAM_H) #define V4L2_STD_DK (V4L2_STD_PAL_DK|V4L2_STD_SECAM_DK) /* some common needed stuff */ #define V4L2_STD_PAL_BG (V4L2_STD_PAL_B |\ V4L2_STD_PAL_B1 |\ V4L2_STD_PAL_G) #define V4L2_STD_PAL_DK (V4L2_STD_PAL_D |\ V4L2_STD_PAL_D1 |\ V4L2_STD_PAL_K) #define V4L2_STD_PAL (V4L2_STD_PAL_BG |\ V4L2_STD_PAL_DK |\ V4L2_STD_PAL_H |\ V4L2_STD_PAL_I) #define V4L2_STD_NTSC (V4L2_STD_NTSC_M |\ V4L2_STD_NTSC_M_JP |\ V4L2_STD_NTSC_M_KR) #define V4L2_STD_SECAM_DK (V4L2_STD_SECAM_D |\ V4L2_STD_SECAM_K |\ V4L2_STD_SECAM_K1) #define V4L2_STD_SECAM (V4L2_STD_SECAM_B |\ V4L2_STD_SECAM_G |\ V4L2_STD_SECAM_H |\ V4L2_STD_SECAM_DK |\ V4L2_STD_SECAM_L |\ V4L2_STD_SECAM_LC) #define V4L2_STD_525_60 (V4L2_STD_PAL_M |\ V4L2_STD_PAL_60 |\ V4L2_STD_NTSC |\ V4L2_STD_NTSC_443) #define V4L2_STD_625_50 (V4L2_STD_PAL |\ V4L2_STD_PAL_N |\ V4L2_STD_PAL_Nc |\ V4L2_STD_SECAM) #define V4L2_STD_ATSC (V4L2_STD_ATSC_8_VSB |\ V4L2_STD_ATSC_16_VSB) #define V4L2_STD_UNKNOWN 0 #define V4L2_STD_ALL (V4L2_STD_525_60 |\ V4L2_STD_625_50) struct v4l2_standard { __u32 index; v4l2_std_id id; __u8 name[24]; struct v4l2_fract frameperiod; /* Frames, not fields */ __u32 framelines; __u32 reserved[4]; }; /* * V I D E O I N P U T S */ struct v4l2_input { __u32 index; /* Which input */ __u8 name[32]; /* Label */ __u32 type; /* Type of input */ __u32 audioset; /* Associated audios (bitfield) */ __u32 tuner; /* Associated tuner */ v4l2_std_id std; __u32 status; __u32 reserved[4]; }; /* Values for the 'type' field */ #define V4L2_INPUT_TYPE_TUNER 1 #define V4L2_INPUT_TYPE_CAMERA 2 /* field 'status' - general */ #define V4L2_IN_ST_NO_POWER 0x00000001 /* Attached device is off */ #define V4L2_IN_ST_NO_SIGNAL 0x00000002 #define V4L2_IN_ST_NO_COLOR 0x00000004 /* field 'status' - sensor orientation */ /* If sensor is mounted upside down set both bits */ #define V4L2_IN_ST_HFLIP 0x00000010 /* Frames are flipped horizontally */ #define V4L2_IN_ST_VFLIP 0x00000020 /* Frames are flipped vertically */ /* field 'status' - analog */ #define V4L2_IN_ST_NO_H_LOCK 0x00000100 /* No horizontal sync lock */ #define V4L2_IN_ST_COLOR_KILL 0x00000200 /* Color killer is active */ /* field 'status' - digital */ #define V4L2_IN_ST_NO_SYNC 0x00010000 /* No synchronization lock */ #define V4L2_IN_ST_NO_EQU 0x00020000 /* No equalizer lock */ #define V4L2_IN_ST_NO_CARRIER 0x00040000 /* Carrier recovery failed */ /* field 'status' - VCR and set-top box */ #define V4L2_IN_ST_MACROVISION 0x01000000 /* Macrovision detected */ #define V4L2_IN_ST_NO_ACCESS 0x02000000 /* Conditional access denied */ #define V4L2_IN_ST_VTR 0x04000000 /* VTR time constant */ /* * V I D E O O U T P U T S */ struct v4l2_output { __u32 index; /* Which output */ __u8 name[32]; /* Label */ __u32 type; /* Type of output */ __u32 audioset; /* Associated audios (bitfield) */ __u32 modulator; /* Associated modulator */ v4l2_std_id std; __u32 reserved[4]; }; /* Values for the 'type' field */ #define V4L2_OUTPUT_TYPE_MODULATOR 1 #define V4L2_OUTPUT_TYPE_ANALOG 2 #define V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY 3 /* * C O N T R O L S */ struct v4l2_control { __u32 id; __s32 value; }; struct v4l2_ext_control { __u32 id; __u32 reserved2[2]; union { __s32 value; __s64 value64; void *reserved; }; } __attribute__ ((packed)); struct v4l2_ext_controls { __u32 ctrl_class; __u32 count; __u32 error_idx; __u32 reserved[2]; struct v4l2_ext_control *controls; }; /* Values for ctrl_class field */ #define V4L2_CTRL_CLASS_USER 0x00980000 /* Old-style 'user' controls */ #define V4L2_CTRL_CLASS_MPEG 0x00990000 /* MPEG-compression controls */ #define V4L2_CTRL_CLASS_CAMERA 0x009a0000 /* Camera class controls */ #define V4L2_CTRL_ID_MASK (0x0fffffff) #define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL) #define V4L2_CTRL_DRIVER_PRIV(id) (((id) & 0xffff) >= 0x1000) /* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */ struct v4l2_queryctrl { __u32 id; enum v4l2_ctrl_type type; __u8 name[32]; /* Whatever */ __s32 minimum; /* Note signedness */ __s32 maximum; __s32 step; __s32 default_value; __u32 flags; __u32 reserved[2]; }; /* Used in the VIDIOC_QUERYMENU ioctl for querying menu items */ struct v4l2_querymenu { __u32 id; __u32 index; __u8 name[32]; /* Whatever */ __u32 reserved; }; /* Control flags */ #define V4L2_CTRL_FLAG_DISABLED 0x0001 #define V4L2_CTRL_FLAG_GRABBED 0x0002 #define V4L2_CTRL_FLAG_READ_ONLY 0x0004 #define V4L2_CTRL_FLAG_UPDATE 0x0008 #define V4L2_CTRL_FLAG_INACTIVE 0x0010 #define V4L2_CTRL_FLAG_SLIDER 0x0020 #define V4L2_CTRL_FLAG_WRITE_ONLY 0x0040 /* Query flag, to be ORed with the control ID */ #define V4L2_CTRL_FLAG_NEXT_CTRL 0x80000000 /* User-class control IDs defined by V4L2 */ #define V4L2_CID_BASE (V4L2_CTRL_CLASS_USER | 0x900) #define V4L2_CID_USER_BASE V4L2_CID_BASE /* IDs reserved for driver specific controls */ #define V4L2_CID_PRIVATE_BASE 0x08000000 #define V4L2_CID_USER_CLASS (V4L2_CTRL_CLASS_USER | 1) #define V4L2_CID_BRIGHTNESS (V4L2_CID_BASE+0) #define V4L2_CID_CONTRAST (V4L2_CID_BASE+1) #define V4L2_CID_SATURATION (V4L2_CID_BASE+2) #define V4L2_CID_HUE (V4L2_CID_BASE+3) #define V4L2_CID_AUDIO_VOLUME (V4L2_CID_BASE+5) #define V4L2_CID_AUDIO_BALANCE (V4L2_CID_BASE+6) #define V4L2_CID_AUDIO_BASS (V4L2_CID_BASE+7) #define V4L2_CID_AUDIO_TREBLE (V4L2_CID_BASE+8) #define V4L2_CID_AUDIO_MUTE (V4L2_CID_BASE+9) #define V4L2_CID_AUDIO_LOUDNESS (V4L2_CID_BASE+10) #define V4L2_CID_BLACK_LEVEL (V4L2_CID_BASE+11) /* Deprecated */ #define V4L2_CID_AUTO_WHITE_BALANCE (V4L2_CID_BASE+12) #define V4L2_CID_DO_WHITE_BALANCE (V4L2_CID_BASE+13) #define V4L2_CID_RED_BALANCE (V4L2_CID_BASE+14) #define V4L2_CID_BLUE_BALANCE (V4L2_CID_BASE+15) #define V4L2_CID_GAMMA (V4L2_CID_BASE+16) #define V4L2_CID_WHITENESS (V4L2_CID_GAMMA) /* Deprecated */ #define V4L2_CID_EXPOSURE (V4L2_CID_BASE+17) #define V4L2_CID_AUTOGAIN (V4L2_CID_BASE+18) #define V4L2_CID_GAIN (V4L2_CID_BASE+19) #define V4L2_CID_HFLIP (V4L2_CID_BASE+20) #define V4L2_CID_VFLIP (V4L2_CID_BASE+21) /* Deprecated; use V4L2_CID_PAN_RESET and V4L2_CID_TILT_RESET */ #define V4L2_CID_HCENTER (V4L2_CID_BASE+22) #define V4L2_CID_VCENTER (V4L2_CID_BASE+23) #define V4L2_CID_POWER_LINE_FREQUENCY (V4L2_CID_BASE+24) enum v4l2_power_line_frequency { V4L2_CID_POWER_LINE_FREQUENCY_DISABLED = 0, V4L2_CID_POWER_LINE_FREQUENCY_50HZ = 1, V4L2_CID_POWER_LINE_FREQUENCY_60HZ = 2, }; #define V4L2_CID_HUE_AUTO (V4L2_CID_BASE+25) #define V4L2_CID_WHITE_BALANCE_TEMPERATURE (V4L2_CID_BASE+26) #define V4L2_CID_SHARPNESS (V4L2_CID_BASE+27) #define V4L2_CID_BACKLIGHT_COMPENSATION (V4L2_CID_BASE+28) #define V4L2_CID_CHROMA_AGC (V4L2_CID_BASE+29) #define V4L2_CID_COLOR_KILLER (V4L2_CID_BASE+30) #define V4L2_CID_COLORFX (V4L2_CID_BASE+31) enum v4l2_colorfx { V4L2_COLORFX_NONE = 0, V4L2_COLORFX_BW = 1, V4L2_COLORFX_SEPIA = 2, }; /* last CID + 1 */ #define V4L2_CID_LASTP1 (V4L2_CID_BASE+32) /* MPEG-class control IDs defined by V4L2 */ #define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900) #define V4L2_CID_MPEG_CLASS (V4L2_CTRL_CLASS_MPEG | 1) /* MPEG streams */ #define V4L2_CID_MPEG_STREAM_TYPE (V4L2_CID_MPEG_BASE+0) enum v4l2_mpeg_stream_type { V4L2_MPEG_STREAM_TYPE_MPEG2_PS = 0, /* MPEG-2 program stream */ V4L2_MPEG_STREAM_TYPE_MPEG2_TS = 1, /* MPEG-2 transport stream */ V4L2_MPEG_STREAM_TYPE_MPEG1_SS = 2, /* MPEG-1 system stream */ V4L2_MPEG_STREAM_TYPE_MPEG2_DVD = 3, /* MPEG-2 DVD-compatible stream */ V4L2_MPEG_STREAM_TYPE_MPEG1_VCD = 4, /* MPEG-1 VCD-compatible stream */ V4L2_MPEG_STREAM_TYPE_MPEG2_SVCD = 5, /* MPEG-2 SVCD-compatible stream */ }; #define V4L2_CID_MPEG_STREAM_PID_PMT (V4L2_CID_MPEG_BASE+1) #define V4L2_CID_MPEG_STREAM_PID_AUDIO (V4L2_CID_MPEG_BASE+2) #define V4L2_CID_MPEG_STREAM_PID_VIDEO (V4L2_CID_MPEG_BASE+3) #define V4L2_CID_MPEG_STREAM_PID_PCR (V4L2_CID_MPEG_BASE+4) #define V4L2_CID_MPEG_STREAM_PES_ID_AUDIO (V4L2_CID_MPEG_BASE+5) #define V4L2_CID_MPEG_STREAM_PES_ID_VIDEO (V4L2_CID_MPEG_BASE+6) #define V4L2_CID_MPEG_STREAM_VBI_FMT (V4L2_CID_MPEG_BASE+7) enum v4l2_mpeg_stream_vbi_fmt { V4L2_MPEG_STREAM_VBI_FMT_NONE = 0, /* No VBI in the MPEG stream */ V4L2_MPEG_STREAM_VBI_FMT_IVTV = 1, /* VBI in private packets, IVTV format */ }; /* MPEG audio */ #define V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ (V4L2_CID_MPEG_BASE+100) enum v4l2_mpeg_audio_sampling_freq { V4L2_MPEG_AUDIO_SAMPLING_FREQ_44100 = 0, V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000 = 1, V4L2_MPEG_AUDIO_SAMPLING_FREQ_32000 = 2, }; #define V4L2_CID_MPEG_AUDIO_ENCODING (V4L2_CID_MPEG_BASE+101) enum v4l2_mpeg_audio_encoding { V4L2_MPEG_AUDIO_ENCODING_LAYER_1 = 0, V4L2_MPEG_AUDIO_ENCODING_LAYER_2 = 1, V4L2_MPEG_AUDIO_ENCODING_LAYER_3 = 2, V4L2_MPEG_AUDIO_ENCODING_AAC = 3, V4L2_MPEG_AUDIO_ENCODING_AC3 = 4, }; #define V4L2_CID_MPEG_AUDIO_L1_BITRATE (V4L2_CID_MPEG_BASE+102) enum v4l2_mpeg_audio_l1_bitrate { V4L2_MPEG_AUDIO_L1_BITRATE_32K = 0, V4L2_MPEG_AUDIO_L1_BITRATE_64K = 1, V4L2_MPEG_AUDIO_L1_BITRATE_96K = 2, V4L2_MPEG_AUDIO_L1_BITRATE_128K = 3, V4L2_MPEG_AUDIO_L1_BITRATE_160K = 4, V4L2_MPEG_AUDIO_L1_BITRATE_192K = 5, V4L2_MPEG_AUDIO_L1_BITRATE_224K = 6, V4L2_MPEG_AUDIO_L1_BITRATE_256K = 7, V4L2_MPEG_AUDIO_L1_BITRATE_288K = 8, V4L2_MPEG_AUDIO_L1_BITRATE_320K = 9, V4L2_MPEG_AUDIO_L1_BITRATE_352K = 10, V4L2_MPEG_AUDIO_L1_BITRATE_384K = 11, V4L2_MPEG_AUDIO_L1_BITRATE_416K = 12, V4L2_MPEG_AUDIO_L1_BITRATE_448K = 13, }; #define V4L2_CID_MPEG_AUDIO_L2_BITRATE (V4L2_CID_MPEG_BASE+103) enum v4l2_mpeg_audio_l2_bitrate { V4L2_MPEG_AUDIO_L2_BITRATE_32K = 0, V4L2_MPEG_AUDIO_L2_BITRATE_48K = 1, V4L2_MPEG_AUDIO_L2_BITRATE_56K = 2, V4L2_MPEG_AUDIO_L2_BITRATE_64K = 3, V4L2_MPEG_AUDIO_L2_BITRATE_80K = 4, V4L2_MPEG_AUDIO_L2_BITRATE_96K = 5, V4L2_MPEG_AUDIO_L2_BITRATE_112K = 6, V4L2_MPEG_AUDIO_L2_BITRATE_128K = 7, V4L2_MPEG_AUDIO_L2_BITRATE_160K = 8, V4L2_MPEG_AUDIO_L2_BITRATE_192K = 9, V4L2_MPEG_AUDIO_L2_BITRATE_224K = 10, V4L2_MPEG_AUDIO_L2_BITRATE_256K = 11, V4L2_MPEG_AUDIO_L2_BITRATE_320K = 12, V4L2_MPEG_AUDIO_L2_BITRATE_384K = 13, }; #define V4L2_CID_MPEG_AUDIO_L3_BITRATE (V4L2_CID_MPEG_BASE+104) enum v4l2_mpeg_audio_l3_bitrate { V4L2_MPEG_AUDIO_L3_BITRATE_32K = 0, V4L2_MPEG_AUDIO_L3_BITRATE_40K = 1, V4L2_MPEG_AUDIO_L3_BITRATE_48K = 2, V4L2_MPEG_AUDIO_L3_BITRATE_56K = 3, V4L2_MPEG_AUDIO_L3_BITRATE_64K = 4, V4L2_MPEG_AUDIO_L3_BITRATE_80K = 5, V4L2_MPEG_AUDIO_L3_BITRATE_96K = 6, V4L2_MPEG_AUDIO_L3_BITRATE_112K = 7, V4L2_MPEG_AUDIO_L3_BITRATE_128K = 8, V4L2_MPEG_AUDIO_L3_BITRATE_160K = 9, V4L2_MPEG_AUDIO_L3_BITRATE_192K = 10, V4L2_MPEG_AUDIO_L3_BITRATE_224K = 11, V4L2_MPEG_AUDIO_L3_BITRATE_256K = 12, V4L2_MPEG_AUDIO_L3_BITRATE_320K = 13, }; #define V4L2_CID_MPEG_AUDIO_MODE (V4L2_CID_MPEG_BASE+105) enum v4l2_mpeg_audio_mode { V4L2_MPEG_AUDIO_MODE_STEREO = 0, V4L2_MPEG_AUDIO_MODE_JOINT_STEREO = 1, V4L2_MPEG_AUDIO_MODE_DUAL = 2, V4L2_MPEG_AUDIO_MODE_MONO = 3, }; #define V4L2_CID_MPEG_AUDIO_MODE_EXTENSION (V4L2_CID_MPEG_BASE+106) enum v4l2_mpeg_audio_mode_extension { V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_4 = 0, V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_8 = 1, V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_12 = 2, V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_16 = 3, }; #define V4L2_CID_MPEG_AUDIO_EMPHASIS (V4L2_CID_MPEG_BASE+107) enum v4l2_mpeg_audio_emphasis { V4L2_MPEG_AUDIO_EMPHASIS_NONE = 0, V4L2_MPEG_AUDIO_EMPHASIS_50_DIV_15_uS = 1, V4L2_MPEG_AUDIO_EMPHASIS_CCITT_J17 = 2, }; #define V4L2_CID_MPEG_AUDIO_CRC (V4L2_CID_MPEG_BASE+108) enum v4l2_mpeg_audio_crc { V4L2_MPEG_AUDIO_CRC_NONE = 0, V4L2_MPEG_AUDIO_CRC_CRC16 = 1, }; #define V4L2_CID_MPEG_AUDIO_MUTE (V4L2_CID_MPEG_BASE+109) #define V4L2_CID_MPEG_AUDIO_AAC_BITRATE (V4L2_CID_MPEG_BASE+110) #define V4L2_CID_MPEG_AUDIO_AC3_BITRATE (V4L2_CID_MPEG_BASE+111) enum v4l2_mpeg_audio_ac3_bitrate { V4L2_MPEG_AUDIO_AC3_BITRATE_32K = 0, V4L2_MPEG_AUDIO_AC3_BITRATE_40K = 1, V4L2_MPEG_AUDIO_AC3_BITRATE_48K = 2, V4L2_MPEG_AUDIO_AC3_BITRATE_56K = 3, V4L2_MPEG_AUDIO_AC3_BITRATE_64K = 4, V4L2_MPEG_AUDIO_AC3_BITRATE_80K = 5, V4L2_MPEG_AUDIO_AC3_BITRATE_96K = 6, V4L2_MPEG_AUDIO_AC3_BITRATE_112K = 7, V4L2_MPEG_AUDIO_AC3_BITRATE_128K = 8, V4L2_MPEG_AUDIO_AC3_BITRATE_160K = 9, V4L2_MPEG_AUDIO_AC3_BITRATE_192K = 10, V4L2_MPEG_AUDIO_AC3_BITRATE_224K = 11, V4L2_MPEG_AUDIO_AC3_BITRATE_256K = 12, V4L2_MPEG_AUDIO_AC3_BITRATE_320K = 13, V4L2_MPEG_AUDIO_AC3_BITRATE_384K = 14, V4L2_MPEG_AUDIO_AC3_BITRATE_448K = 15, V4L2_MPEG_AUDIO_AC3_BITRATE_512K = 16, V4L2_MPEG_AUDIO_AC3_BITRATE_576K = 17, V4L2_MPEG_AUDIO_AC3_BITRATE_640K = 18, }; /* MPEG video */ #define V4L2_CID_MPEG_VIDEO_ENCODING (V4L2_CID_MPEG_BASE+200) enum v4l2_mpeg_video_encoding { V4L2_MPEG_VIDEO_ENCODING_MPEG_1 = 0, V4L2_MPEG_VIDEO_ENCODING_MPEG_2 = 1, V4L2_MPEG_VIDEO_ENCODING_MPEG_4_AVC = 2, }; #define V4L2_CID_MPEG_VIDEO_ASPECT (V4L2_CID_MPEG_BASE+201) enum v4l2_mpeg_video_aspect { V4L2_MPEG_VIDEO_ASPECT_1x1 = 0, V4L2_MPEG_VIDEO_ASPECT_4x3 = 1, V4L2_MPEG_VIDEO_ASPECT_16x9 = 2, V4L2_MPEG_VIDEO_ASPECT_221x100 = 3, }; #define V4L2_CID_MPEG_VIDEO_B_FRAMES (V4L2_CID_MPEG_BASE+202) #define V4L2_CID_MPEG_VIDEO_GOP_SIZE (V4L2_CID_MPEG_BASE+203) #define V4L2_CID_MPEG_VIDEO_GOP_CLOSURE (V4L2_CID_MPEG_BASE+204) #define V4L2_CID_MPEG_VIDEO_PULLDOWN (V4L2_CID_MPEG_BASE+205) #define V4L2_CID_MPEG_VIDEO_BITRATE_MODE (V4L2_CID_MPEG_BASE+206) enum v4l2_mpeg_video_bitrate_mode { V4L2_MPEG_VIDEO_BITRATE_MODE_VBR = 0, V4L2_MPEG_VIDEO_BITRATE_MODE_CBR = 1, }; #define V4L2_CID_MPEG_VIDEO_BITRATE (V4L2_CID_MPEG_BASE+207) #define V4L2_CID_MPEG_VIDEO_BITRATE_PEAK (V4L2_CID_MPEG_BASE+208) #define V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION (V4L2_CID_MPEG_BASE+209) #define V4L2_CID_MPEG_VIDEO_MUTE (V4L2_CID_MPEG_BASE+210) #define V4L2_CID_MPEG_VIDEO_MUTE_YUV (V4L2_CID_MPEG_BASE+211) /* MPEG-class control IDs specific to the CX2341x driver as defined by V4L2 */ #define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000) #define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+0) enum v4l2_mpeg_cx2341x_video_spatial_filter_mode { V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_MANUAL = 0, V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_AUTO = 1, }; #define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER (V4L2_CID_MPEG_CX2341X_BASE+1) #define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+2) enum v4l2_mpeg_cx2341x_video_luma_spatial_filter_type { V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_OFF = 0, V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_HOR = 1, V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_VERT = 2, V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_HV_SEPARABLE = 3, V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_SYM_NON_SEPARABLE = 4, }; #define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+3) enum v4l2_mpeg_cx2341x_video_chroma_spatial_filter_type { V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_OFF = 0, V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_1D_HOR = 1, }; #define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+4) enum v4l2_mpeg_cx2341x_video_temporal_filter_mode { V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_MANUAL = 0, V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_AUTO = 1, }; #define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER (V4L2_CID_MPEG_CX2341X_BASE+5) #define V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+6) enum v4l2_mpeg_cx2341x_video_median_filter_type { V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF = 0, V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR = 1, V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_VERT = 2, V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR_VERT = 3, V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_DIAG = 4, }; #define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_BOTTOM (V4L2_CID_MPEG_CX2341X_BASE+7) #define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+8) #define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM (V4L2_CID_MPEG_CX2341X_BASE+9) #define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+10) #define V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS (V4L2_CID_MPEG_CX2341X_BASE+11) /* Camera class control IDs */ #define V4L2_CID_CAMERA_CLASS_BASE (V4L2_CTRL_CLASS_CAMERA | 0x900) #define V4L2_CID_CAMERA_CLASS (V4L2_CTRL_CLASS_CAMERA | 1) #define V4L2_CID_EXPOSURE_AUTO (V4L2_CID_CAMERA_CLASS_BASE+1) enum v4l2_exposure_auto_type { V4L2_EXPOSURE_AUTO = 0, V4L2_EXPOSURE_MANUAL = 1, V4L2_EXPOSURE_SHUTTER_PRIORITY = 2, V4L2_EXPOSURE_APERTURE_PRIORITY = 3 }; #define V4L2_CID_EXPOSURE_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+2) #define V4L2_CID_EXPOSURE_AUTO_PRIORITY (V4L2_CID_CAMERA_CLASS_BASE+3) #define V4L2_CID_PAN_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+4) #define V4L2_CID_TILT_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+5) #define V4L2_CID_PAN_RESET (V4L2_CID_CAMERA_CLASS_BASE+6) #define V4L2_CID_TILT_RESET (V4L2_CID_CAMERA_CLASS_BASE+7) #define V4L2_CID_PAN_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+8) #define V4L2_CID_TILT_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+9) #define V4L2_CID_FOCUS_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+10) #define V4L2_CID_FOCUS_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+11) #define V4L2_CID_FOCUS_AUTO (V4L2_CID_CAMERA_CLASS_BASE+12) #define V4L2_CID_ZOOM_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+13) #define V4L2_CID_ZOOM_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+14) #define V4L2_CID_ZOOM_CONTINUOUS (V4L2_CID_CAMERA_CLASS_BASE+15) #define V4L2_CID_PRIVACY (V4L2_CID_CAMERA_CLASS_BASE+16) /* * T U N I N G */ struct v4l2_tuner { __u32 index; __u8 name[32]; enum v4l2_tuner_type type; __u32 capability; __u32 rangelow; __u32 rangehigh; __u32 rxsubchans; __u32 audmode; __s32 signal; __s32 afc; __u32 reserved[4]; }; struct v4l2_modulator { __u32 index; __u8 name[32]; __u32 capability; __u32 rangelow; __u32 rangehigh; __u32 txsubchans; __u32 reserved[4]; }; /* Flags for the 'capability' field */ #define V4L2_TUNER_CAP_LOW 0x0001 #define V4L2_TUNER_CAP_NORM 0x0002 #define V4L2_TUNER_CAP_STEREO 0x0010 #define V4L2_TUNER_CAP_LANG2 0x0020 #define V4L2_TUNER_CAP_SAP 0x0020 #define V4L2_TUNER_CAP_LANG1 0x0040 /* Flags for the 'rxsubchans' field */ #define V4L2_TUNER_SUB_MONO 0x0001 #define V4L2_TUNER_SUB_STEREO 0x0002 #define V4L2_TUNER_SUB_LANG2 0x0004 #define V4L2_TUNER_SUB_SAP 0x0004 #define V4L2_TUNER_SUB_LANG1 0x0008 /* Values for the 'audmode' field */ #define V4L2_TUNER_MODE_MONO 0x0000 #define V4L2_TUNER_MODE_STEREO 0x0001 #define V4L2_TUNER_MODE_LANG2 0x0002 #define V4L2_TUNER_MODE_SAP 0x0002 #define V4L2_TUNER_MODE_LANG1 0x0003 #define V4L2_TUNER_MODE_LANG1_LANG2 0x0004 struct v4l2_frequency { __u32 tuner; enum v4l2_tuner_type type; __u32 frequency; __u32 reserved[8]; }; struct v4l2_hw_freq_seek { __u32 tuner; enum v4l2_tuner_type type; __u32 seek_upward; __u32 wrap_around; __u32 reserved[8]; }; /* * A U D I O */ struct v4l2_audio { __u32 index; __u8 name[32]; __u32 capability; __u32 mode; __u32 reserved[2]; }; /* Flags for the 'capability' field */ #define V4L2_AUDCAP_STEREO 0x00001 #define V4L2_AUDCAP_AVL 0x00002 /* Flags for the 'mode' field */ #define V4L2_AUDMODE_AVL 0x00001 struct v4l2_audioout { __u32 index; __u8 name[32]; __u32 capability; __u32 mode; __u32 reserved[2]; }; /* * M P E G S E R V I C E S * * NOTE: EXPERIMENTAL API */ #if 1 /*KEEP*/ #define V4L2_ENC_IDX_FRAME_I (0) #define V4L2_ENC_IDX_FRAME_P (1) #define V4L2_ENC_IDX_FRAME_B (2) #define V4L2_ENC_IDX_FRAME_MASK (0xf) struct v4l2_enc_idx_entry { __u64 offset; __u64 pts; __u32 length; __u32 flags; __u32 reserved[2]; }; #define V4L2_ENC_IDX_ENTRIES (64) struct v4l2_enc_idx { __u32 entries; __u32 entries_cap; __u32 reserved[4]; struct v4l2_enc_idx_entry entry[V4L2_ENC_IDX_ENTRIES]; }; #define V4L2_ENC_CMD_START (0) #define V4L2_ENC_CMD_STOP (1) #define V4L2_ENC_CMD_PAUSE (2) #define V4L2_ENC_CMD_RESUME (3) /* Flags for V4L2_ENC_CMD_STOP */ #define V4L2_ENC_CMD_STOP_AT_GOP_END (1 << 0) struct v4l2_encoder_cmd { __u32 cmd; __u32 flags; union { struct { __u32 data[8]; } raw; }; }; #endif /* * D A T A S E R V I C E S ( V B I ) * * Data services API by Michael Schimek */ /* Raw VBI */ struct v4l2_vbi_format { __u32 sampling_rate; /* in 1 Hz */ __u32 offset; __u32 samples_per_line; __u32 sample_format; /* V4L2_PIX_FMT_* */ __s32 start[2]; __u32 count[2]; __u32 flags; /* V4L2_VBI_* */ __u32 reserved[2]; /* must be zero */ }; /* VBI flags */ #define V4L2_VBI_UNSYNC (1 << 0) #define V4L2_VBI_INTERLACED (1 << 1) /* Sliced VBI * * This implements is a proposal V4L2 API to allow SLICED VBI * required for some hardware encoders. It should change without * notice in the definitive implementation. */ struct v4l2_sliced_vbi_format { __u16 service_set; /* service_lines[0][...] specifies lines 0-23 (1-23 used) of the first field service_lines[1][...] specifies lines 0-23 (1-23 used) of the second field (equals frame lines 313-336 for 625 line video standards, 263-286 for 525 line standards) */ __u16 service_lines[2][24]; __u32 io_size; __u32 reserved[2]; /* must be zero */ }; /* Teletext World System Teletext (WST), defined on ITU-R BT.653-2 */ #define V4L2_SLICED_TELETEXT_B (0x0001) /* Video Program System, defined on ETS 300 231*/ #define V4L2_SLICED_VPS (0x0400) /* Closed Caption, defined on EIA-608 */ #define V4L2_SLICED_CAPTION_525 (0x1000) /* Wide Screen System, defined on ITU-R BT1119.1 */ #define V4L2_SLICED_WSS_625 (0x4000) #define V4L2_SLICED_VBI_525 (V4L2_SLICED_CAPTION_525) #define V4L2_SLICED_VBI_625 (V4L2_SLICED_TELETEXT_B | V4L2_SLICED_VPS | V4L2_SLICED_WSS_625) struct v4l2_sliced_vbi_cap { __u16 service_set; /* service_lines[0][...] specifies lines 0-23 (1-23 used) of the first field service_lines[1][...] specifies lines 0-23 (1-23 used) of the second field (equals frame lines 313-336 for 625 line video standards, 263-286 for 525 line standards) */ __u16 service_lines[2][24]; enum v4l2_buf_type type; __u32 reserved[3]; /* must be 0 */ }; struct v4l2_sliced_vbi_data { __u32 id; __u32 field; /* 0: first field, 1: second field */ __u32 line; /* 1-23 */ __u32 reserved; /* must be 0 */ __u8 data[48]; }; /* * Sliced VBI data inserted into MPEG Streams */ /* * V4L2_MPEG_STREAM_VBI_FMT_IVTV: * * Structure of payload contained in an MPEG 2 Private Stream 1 PES Packet in an * MPEG-2 Program Pack that contains V4L2_MPEG_STREAM_VBI_FMT_IVTV Sliced VBI * data * * Note, the MPEG-2 Program Pack and Private Stream 1 PES packet header * definitions are not included here. See the MPEG-2 specifications for details * on these headers. */ /* Line type IDs */ #define V4L2_MPEG_VBI_IVTV_TELETEXT_B (1) #define V4L2_MPEG_VBI_IVTV_CAPTION_525 (4) #define V4L2_MPEG_VBI_IVTV_WSS_625 (5) #define V4L2_MPEG_VBI_IVTV_VPS (7) struct v4l2_mpeg_vbi_itv0_line { __u8 id; /* One of V4L2_MPEG_VBI_IVTV_* above */ __u8 data[42]; /* Sliced VBI data for the line */ } __attribute__ ((packed)); struct v4l2_mpeg_vbi_itv0 { __le32 linemask[2]; /* Bitmasks of VBI service lines present */ struct v4l2_mpeg_vbi_itv0_line line[35]; } __attribute__ ((packed)); struct v4l2_mpeg_vbi_ITV0 { struct v4l2_mpeg_vbi_itv0_line line[36]; } __attribute__ ((packed)); #define V4L2_MPEG_VBI_IVTV_MAGIC0 "itv0" #define V4L2_MPEG_VBI_IVTV_MAGIC1 "ITV0" struct v4l2_mpeg_vbi_fmt_ivtv { __u8 magic[4]; union { struct v4l2_mpeg_vbi_itv0 itv0; struct v4l2_mpeg_vbi_ITV0 ITV0; }; } __attribute__ ((packed)); /* * A G G R E G A T E S T R U C T U R E S */ /* Stream data format */ struct v4l2_format { enum v4l2_buf_type type; union { struct v4l2_pix_format pix; /* V4L2_BUF_TYPE_VIDEO_CAPTURE */ struct v4l2_window win; /* V4L2_BUF_TYPE_VIDEO_OVERLAY */ struct v4l2_vbi_format vbi; /* V4L2_BUF_TYPE_VBI_CAPTURE */ struct v4l2_sliced_vbi_format sliced; /* V4L2_BUF_TYPE_SLICED_VBI_CAPTURE */ __u8 raw_data[200]; /* user-defined */ } fmt; }; /* Stream type-dependent parameters */ struct v4l2_streamparm { enum v4l2_buf_type type; union { struct v4l2_captureparm capture; struct v4l2_outputparm output; __u8 raw_data[200]; /* user-defined */ } parm; }; /* * A D V A N C E D D E B U G G I N G * * NOTE: EXPERIMENTAL API, NEVER RELY ON THIS IN APPLICATIONS! * FOR DEBUGGING, TESTING AND INTERNAL USE ONLY! */ /* VIDIOC_DBG_G_REGISTER and VIDIOC_DBG_S_REGISTER */ #define V4L2_CHIP_MATCH_HOST 0 /* Match against chip ID on host (0 for the host) */ #define V4L2_CHIP_MATCH_I2C_DRIVER 1 /* Match against I2C driver name */ #define V4L2_CHIP_MATCH_I2C_ADDR 2 /* Match against I2C 7-bit address */ #define V4L2_CHIP_MATCH_AC97 3 /* Match against anciliary AC97 chip */ struct v4l2_dbg_match { __u32 type; /* Match type */ union { /* Match this chip, meaning determined by type */ __u32 addr; char name[32]; }; } __attribute__ ((packed)); struct v4l2_dbg_register { struct v4l2_dbg_match match; __u32 size; /* register size in bytes */ __u64 reg; __u64 val; } __attribute__ ((packed)); /* VIDIOC_DBG_G_CHIP_IDENT */ struct v4l2_dbg_chip_ident { struct v4l2_dbg_match match; __u32 ident; /* chip identifier as specified in */ __u32 revision; /* chip revision, chip specific */ } __attribute__ ((packed)); /* * I O C T L C O D E S F O R V I D E O D E V I C E S * */ #define VIDIOC_QUERYCAP _IOR('V', 0, struct v4l2_capability) #define VIDIOC_RESERVED _IO('V', 1) #define VIDIOC_ENUM_FMT _IOWR('V', 2, struct v4l2_fmtdesc) #define VIDIOC_G_FMT _IOWR('V', 4, struct v4l2_format) #define VIDIOC_S_FMT _IOWR('V', 5, struct v4l2_format) #define VIDIOC_REQBUFS _IOWR('V', 8, struct v4l2_requestbuffers) #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 _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 _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 _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 _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) #define VIDIOC_G_INPUT _IOR('V', 38, int) #define VIDIOC_S_INPUT _IOWR('V', 39, int) #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 _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) #define VIDIOC_G_FREQUENCY _IOWR('V', 56, struct v4l2_frequency) #define VIDIOC_S_FREQUENCY _IOW('V', 57, struct v4l2_frequency) #define VIDIOC_CROPCAP _IOWR('V', 58, struct v4l2_cropcap) #define VIDIOC_G_CROP _IOWR('V', 59, struct v4l2_crop) #define VIDIOC_S_CROP _IOW('V', 60, struct v4l2_crop) #define VIDIOC_G_JPEGCOMP _IOR('V', 61, struct v4l2_jpegcompression) #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) #define VIDIOC_G_PRIORITY _IOR('V', 67, enum v4l2_priority) #define VIDIOC_S_PRIORITY _IOW('V', 68, enum v4l2_priority) #define VIDIOC_G_SLICED_VBI_CAP _IOWR('V', 69, struct v4l2_sliced_vbi_cap) #define VIDIOC_LOG_STATUS _IO('V', 70) #define VIDIOC_G_EXT_CTRLS _IOWR('V', 71, struct v4l2_ext_controls) #define VIDIOC_S_EXT_CTRLS _IOWR('V', 72, struct v4l2_ext_controls) #define VIDIOC_TRY_EXT_CTRLS _IOWR('V', 73, struct v4l2_ext_controls) #if 1 /*KEEP*/ #define VIDIOC_ENUM_FRAMESIZES _IOWR('V', 74, struct v4l2_frmsizeenum) #define VIDIOC_ENUM_FRAMEINTERVALS _IOWR('V', 75, struct v4l2_frmivalenum) #define VIDIOC_G_ENC_INDEX _IOR('V', 76, struct v4l2_enc_idx) #define VIDIOC_ENCODER_CMD _IOWR('V', 77, struct v4l2_encoder_cmd) #define VIDIOC_TRY_ENCODER_CMD _IOWR('V', 78, struct v4l2_encoder_cmd) #endif #if 1 /*KEEP*/ /* Experimental, meant for debugging, testing and internal use. Only implemented if CONFIG_VIDEO_ADV_DEBUG is defined. You must be root to use these ioctls. Never use these in applications! */ #define VIDIOC_DBG_S_REGISTER _IOW('V', 79, struct v4l2_dbg_register) #define VIDIOC_DBG_G_REGISTER _IOWR('V', 80, struct v4l2_dbg_register) /* Experimental, meant for debugging, testing and internal use. Never use this ioctl in applications! */ #define VIDIOC_DBG_G_CHIP_IDENT _IOWR('V', 81, struct v4l2_dbg_chip_ident) #endif #define VIDIOC_S_HW_FREQ_SEEK _IOW('V', 82, struct v4l2_hw_freq_seek) /* Reminder: when adding new ioctls please add support for them to drivers/media/video/v4l2-compat-ioctl32.c as well! */ #ifdef __OLD_VIDIOC_ /* 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 VIDIOC_CROPCAP_OLD _IOR('V', 58, struct v4l2_cropcap) #endif #define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */ #endif /* __LINUX_VIDEODEV2_H */ ivtv-utils-1.4.1/utils/linux/dvb/0000775000076400007640000000000011355717714015412 5ustar andyandyivtv-utils-1.4.1/utils/linux/dvb/audio.h0000664000076400007640000001144011355717530016660 0ustar andyandy/* * audio.h * * Copyright (C) 2000 Ralph Metzler * & Marcus Metzler * for convergence integrated media GmbH * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Lesser Public License * as published by the Free Software Foundation; either version 2.1 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ #ifndef _DVBAUDIO_H_ #define _DVBAUDIO_H_ #include typedef enum { AUDIO_SOURCE_DEMUX, /* Select the demux as the main source */ AUDIO_SOURCE_MEMORY /* Select internal memory as the main source */ } audio_stream_source_t; typedef enum { AUDIO_STOPPED, /* Device is stopped */ AUDIO_PLAYING, /* Device is currently playing */ AUDIO_PAUSED /* Device is paused */ } audio_play_state_t; typedef enum { AUDIO_STEREO, AUDIO_MONO_LEFT, AUDIO_MONO_RIGHT, AUDIO_MONO, AUDIO_STEREO_SWAPPED } audio_channel_select_t; typedef struct audio_mixer { unsigned int volume_left; unsigned int volume_right; // what else do we need? bass, pass-through, ... } audio_mixer_t; typedef struct audio_status { int AV_sync_state; /* sync audio and video? */ int mute_state; /* audio is muted */ audio_play_state_t play_state; /* current playback state */ audio_stream_source_t stream_source; /* current stream source */ audio_channel_select_t channel_select; /* currently selected channel */ int bypass_mode; /* pass on audio data to */ audio_mixer_t mixer_state; /* current mixer state */ } audio_status_t; /* separate decoder hardware */ typedef struct audio_karaoke{ /* if Vocal1 or Vocal2 are non-zero, they get mixed */ int vocal1; /* into left and right t at 70% each */ int vocal2; /* if both, Vocal1 and Vocal2 are non-zero, Vocal1 gets*/ int melody; /* mixed into the left channel and */ /* Vocal2 into the right channel at 100% each. */ /* if Melody is non-zero, the melody channel gets mixed*/ } audio_karaoke_t; /* into left and right */ typedef uint16_t audio_attributes_t; /* bits: descr. */ /* 15-13 audio coding mode (0=ac3, 2=mpeg1, 3=mpeg2ext, 4=LPCM, 6=DTS, */ /* 12 multichannel extension */ /* 11-10 audio type (0=not spec, 1=language included) */ /* 9- 8 audio application mode (0=not spec, 1=karaoke, 2=surround) */ /* 7- 6 Quantization / DRC (mpeg audio: 1=DRC exists)(lpcm: 0=16bit, */ /* 5- 4 Sample frequency fs (0=48kHz, 1=96kHz) */ /* 2- 0 number of audio channels (n+1 channels) */ /* for GET_CAPABILITIES and SET_FORMAT, the latter should only set one bit */ #define AUDIO_CAP_DTS 1 #define AUDIO_CAP_LPCM 2 #define AUDIO_CAP_MP1 4 #define AUDIO_CAP_MP2 8 #define AUDIO_CAP_MP3 16 #define AUDIO_CAP_AAC 32 #define AUDIO_CAP_OGG 64 #define AUDIO_CAP_SDDS 128 #define AUDIO_CAP_AC3 256 #define AUDIO_STOP _IO('o', 1) #define AUDIO_PLAY _IO('o', 2) #define AUDIO_PAUSE _IO('o', 3) #define AUDIO_CONTINUE _IO('o', 4) #define AUDIO_SELECT_SOURCE _IO('o', 5) #define AUDIO_SET_MUTE _IO('o', 6) #define AUDIO_SET_AV_SYNC _IO('o', 7) #define AUDIO_SET_BYPASS_MODE _IO('o', 8) #define AUDIO_CHANNEL_SELECT _IO('o', 9) #define AUDIO_GET_STATUS _IOR('o', 10, audio_status_t) #define AUDIO_GET_CAPABILITIES _IOR('o', 11, unsigned int) #define AUDIO_CLEAR_BUFFER _IO('o', 12) #define AUDIO_SET_ID _IO('o', 13) #define AUDIO_SET_MIXER _IOW('o', 14, audio_mixer_t) #define AUDIO_SET_STREAMTYPE _IO('o', 15) #define AUDIO_SET_EXT_ID _IO('o', 16) #define AUDIO_SET_ATTRIBUTES _IOW('o', 17, audio_attributes_t) #define AUDIO_SET_KARAOKE _IOW('o', 18, audio_karaoke_t) /** * AUDIO_GET_PTS * * Read the 33 bit presentation time stamp as defined * in ITU T-REC-H.222.0 / ISO/IEC 13818-1. * * The PTS should belong to the currently played * frame if possible, but may also be a value close to it * like the PTS of the last decoded frame or the last PTS * extracted by the PES parser. */ #define AUDIO_GET_PTS _IOR('o', 19, __u64) #define AUDIO_BILINGUAL_CHANNEL_SELECT _IO('o', 20) #endif /* _DVBAUDIO_H_ */ ivtv-utils-1.4.1/utils/linux/dvb/video.h0000664000076400007640000002100611355717530016664 0ustar andyandy/* * video.h * * Copyright (C) 2000 Marcus Metzler * & Ralph Metzler * for convergence integrated media GmbH * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2.1 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ #ifndef _DVBVIDEO_H_ #define _DVBVIDEO_H_ #include #include #include typedef enum { VIDEO_FORMAT_4_3, /* Select 4:3 format */ VIDEO_FORMAT_16_9, /* Select 16:9 format. */ VIDEO_FORMAT_221_1 /* 2.21:1 */ } video_format_t; typedef enum { VIDEO_SYSTEM_PAL, VIDEO_SYSTEM_NTSC, VIDEO_SYSTEM_PALN, VIDEO_SYSTEM_PALNc, VIDEO_SYSTEM_PALM, VIDEO_SYSTEM_NTSC60, VIDEO_SYSTEM_PAL60, VIDEO_SYSTEM_PALM60 } video_system_t; typedef enum { VIDEO_PAN_SCAN, /* use pan and scan format */ VIDEO_LETTER_BOX, /* use letterbox format */ VIDEO_CENTER_CUT_OUT /* use center cut out format */ } video_displayformat_t; typedef struct { int w; int h; video_format_t aspect_ratio; } video_size_t; typedef enum { VIDEO_SOURCE_DEMUX, /* Select the demux as the main source */ VIDEO_SOURCE_MEMORY /* If this source is selected, the stream comes from the user through the write system call */ } video_stream_source_t; typedef enum { VIDEO_STOPPED, /* Video is stopped */ VIDEO_PLAYING, /* Video is currently playing */ VIDEO_FREEZED /* Video is freezed */ } video_play_state_t; /* Decoder commands */ #define VIDEO_CMD_PLAY (0) #define VIDEO_CMD_STOP (1) #define VIDEO_CMD_FREEZE (2) #define VIDEO_CMD_CONTINUE (3) /* Flags for VIDEO_CMD_FREEZE */ #define VIDEO_CMD_FREEZE_TO_BLACK (1 << 0) /* Flags for VIDEO_CMD_STOP */ #define VIDEO_CMD_STOP_TO_BLACK (1 << 0) #define VIDEO_CMD_STOP_IMMEDIATELY (1 << 1) /* Play input formats: */ /* The decoder has no special format requirements */ #define VIDEO_PLAY_FMT_NONE (0) /* The decoder requires full GOPs */ #define VIDEO_PLAY_FMT_GOP (1) /* The structure must be zeroed before use by the application This ensures it can be extended safely in the future. */ struct video_command { __u32 cmd; __u32 flags; union { struct { __u64 pts; } stop; struct { /* 0 or 1000 specifies normal speed, 1 specifies forward single stepping, -1 specifies backward single stepping, >1: playback at speed/1000 of the normal speed, <-1: reverse playback at (-speed/1000) of the normal speed. */ __s32 speed; __u32 format; } play; struct { __u32 data[16]; } raw; }; }; /* FIELD_UNKNOWN can be used if the hardware does not know whether the Vsync is for an odd, even or progressive (i.e. non-interlaced) field. */ #define VIDEO_VSYNC_FIELD_UNKNOWN (0) #define VIDEO_VSYNC_FIELD_ODD (1) #define VIDEO_VSYNC_FIELD_EVEN (2) #define VIDEO_VSYNC_FIELD_PROGRESSIVE (3) struct video_event { int32_t type; #define VIDEO_EVENT_SIZE_CHANGED 1 #define VIDEO_EVENT_FRAME_RATE_CHANGED 2 #define VIDEO_EVENT_DECODER_STOPPED 3 #define VIDEO_EVENT_VSYNC 4 time_t timestamp; union { video_size_t size; unsigned int frame_rate; /* in frames per 1000sec */ unsigned char vsync_field; /* unknown/odd/even/progressive */ } u; }; struct video_status { int video_blank; /* blank video on freeze? */ video_play_state_t play_state; /* current state of playback */ video_stream_source_t stream_source; /* current source (demux/memory) */ video_format_t video_format; /* current aspect ratio of stream*/ video_displayformat_t display_format;/* selected cropping mode */ }; struct video_still_picture { char *iFrame; /* pointer to a single iframe in memory */ int32_t size; }; typedef struct video_highlight { int active; /* 1=show highlight, 0=hide highlight */ uint8_t contrast1; /* 7- 4 Pattern pixel contrast */ /* 3- 0 Background pixel contrast */ uint8_t contrast2; /* 7- 4 Emphasis pixel-2 contrast */ /* 3- 0 Emphasis pixel-1 contrast */ uint8_t color1; /* 7- 4 Pattern pixel color */ /* 3- 0 Background pixel color */ uint8_t color2; /* 7- 4 Emphasis pixel-2 color */ /* 3- 0 Emphasis pixel-1 color */ uint32_t ypos; /* 23-22 auto action mode */ /* 21-12 start y */ /* 9- 0 end y */ uint32_t xpos; /* 23-22 button color number */ /* 21-12 start x */ /* 9- 0 end x */ } video_highlight_t; typedef struct video_spu { int active; int stream_id; } video_spu_t; typedef struct video_spu_palette { /* SPU Palette information */ int length; uint8_t *palette; } video_spu_palette_t; typedef struct video_navi_pack { int length; /* 0 ... 1024 */ uint8_t data[1024]; } video_navi_pack_t; typedef uint16_t video_attributes_t; /* bits: descr. */ /* 15-14 Video compression mode (0=MPEG-1, 1=MPEG-2) */ /* 13-12 TV system (0=525/60, 1=625/50) */ /* 11-10 Aspect ratio (0=4:3, 3=16:9) */ /* 9- 8 permitted display mode on 4:3 monitor (0=both, 1=only pan-sca */ /* 7 line 21-1 data present in GOP (1=yes, 0=no) */ /* 6 line 21-2 data present in GOP (1=yes, 0=no) */ /* 5- 3 source resolution (0=720x480/576, 1=704x480/576, 2=352x480/57 */ /* 2 source letterboxed (1=yes, 0=no) */ /* 0 film/camera mode (0=camera, 1=film (625/50 only)) */ /* bit definitions for capabilities: */ /* can the hardware decode MPEG1 and/or MPEG2? */ #define VIDEO_CAP_MPEG1 1 #define VIDEO_CAP_MPEG2 2 /* can you send a system and/or program stream to video device? (you still have to open the video and the audio device but only send the stream to the video device) */ #define VIDEO_CAP_SYS 4 #define VIDEO_CAP_PROG 8 /* can the driver also handle SPU, NAVI and CSS encoded data? (CSS API is not present yet) */ #define VIDEO_CAP_SPU 16 #define VIDEO_CAP_NAVI 32 #define VIDEO_CAP_CSS 64 #define VIDEO_STOP _IO('o', 21) #define VIDEO_PLAY _IO('o', 22) #define VIDEO_FREEZE _IO('o', 23) #define VIDEO_CONTINUE _IO('o', 24) #define VIDEO_SELECT_SOURCE _IO('o', 25) #define VIDEO_SET_BLANK _IO('o', 26) #define VIDEO_GET_STATUS _IOR('o', 27, struct video_status) #define VIDEO_GET_EVENT _IOR('o', 28, struct video_event) #define VIDEO_SET_DISPLAY_FORMAT _IO('o', 29) #define VIDEO_STILLPICTURE _IOW('o', 30, struct video_still_picture) #define VIDEO_FAST_FORWARD _IO('o', 31) #define VIDEO_SLOWMOTION _IO('o', 32) #define VIDEO_GET_CAPABILITIES _IOR('o', 33, unsigned int) #define VIDEO_CLEAR_BUFFER _IO('o', 34) #define VIDEO_SET_ID _IO('o', 35) #define VIDEO_SET_STREAMTYPE _IO('o', 36) #define VIDEO_SET_FORMAT _IO('o', 37) #define VIDEO_SET_SYSTEM _IO('o', 38) #define VIDEO_SET_HIGHLIGHT _IOW('o', 39, video_highlight_t) #define VIDEO_SET_SPU _IOW('o', 50, video_spu_t) #define VIDEO_SET_SPU_PALETTE _IOW('o', 51, video_spu_palette_t) #define VIDEO_GET_NAVI _IOR('o', 52, video_navi_pack_t) #define VIDEO_SET_ATTRIBUTES _IO('o', 53) #define VIDEO_GET_SIZE _IOR('o', 55, video_size_t) #define VIDEO_GET_FRAME_RATE _IOR('o', 56, unsigned int) /** * VIDEO_GET_PTS * * Read the 33 bit presentation time stamp as defined * in ITU T-REC-H.222.0 / ISO/IEC 13818-1. * * The PTS should belong to the currently played * frame if possible, but may also be a value close to it * like the PTS of the last decoded frame or the last PTS * extracted by the PES parser. */ #define VIDEO_GET_PTS _IOR('o', 57, __u64) /* Read the number of displayed frames since the decoder was started */ #define VIDEO_GET_FRAME_COUNT _IOR('o', 58, __u64) #define VIDEO_COMMAND _IOWR('o', 59, struct video_command) #define VIDEO_TRY_COMMAND _IOWR('o', 60, struct video_command) #endif /*_DVBVIDEO_H_*/ ivtv-utils-1.4.1/utils/ivtvfwextract.pl0000775000076400007640000002430611355717530016761 0ustar andyandy#! /usr/bin/perl # # ivtvfwextract: Find and extract firmware for Hauppage WinTV-PVR-250 and 350. # # Copyright (C) 2003 Hans-Peter Nilsson. # Distributable under the GNU General Public License, # see . # # Options: # --split: # Split each of the images into two files with 128k each. Any # specified encoder and decoder firmware image names are taken # to be prefixes, and "-1.bin" and "-2.bin" are suffixed. # # this is legacy. Use --no-split unless you have an old ver of # the driver # # --no-split: (default) # Don't perform any split: write the full 256k into single # files. # # --use-encoder-image=N, N = 1 or N = 2. # Retrieve the encoder image number N, emit error if only one. # # --no-unzip: # The driver file isn't zipped file. # # $ARGV[0]: Location of mounted cdrom or filename of zipped drivers. # (default /mnt/cdrom). # Or the driver filename when you set "--no-unzip" option. # # $ARGV[1]: If this is a directory: location (default /lib/modules) where # to put firmware files ivtv-enc-fw.bin and ivtv-dec-fw.bin, or # when --split is in effect, files ivtv-enc-fw-1.bin, # ivtv-enc-fw-2.bin, ivtv-dec-fw-1.bin and ivtv-dec-fw-2.bin. # If this is a nonexistent filename or existing file: filename # (prefix if --split in effect) where to put encoder firmware. # # $ARGV[2]: Filename to put decoder firmware. # # Examples: # ivtvfwextract # ivtvfwextract --use-encoder-image=2 pvr48xxx.exe # ivtvfwextract --no-split /mnt/cdrom /tmp/enc.img /tmp/dec.img use Getopt::Long; $packed_driver_name = "pvr48xxx.exe"; $fw_driver_name = "hcwpvrp2.sys"; # for Yuan MPG600/MPG160 #$fw_driver_name = "p2driver.sys"; $decoder_magic = "a703000066bb55aa"; $encoder_magic = "a70d000066bb55aa"; # Remember to adjust the usage-text and the $encoder_path and # $decoder_path settings if you change the default to --no-split. $do_split = 0; $do_not_split = -1; $do_help = 0; $use_encoder_img = -1; $no_unzip = 0; $default_readpath = "/mnt/cdrom"; $default_destpath = "/lib/modules"; $default_encname = "ivtv-fw-enc"; $default_decname = "ivtv-fw-dec"; sub bye; # There's no useful version string to grep for, so let's just key off # the "usage" message we get with no parameters specified. bye ("Can't find required program unzip in your PATH") unless `unzip` =~ /Usage:/; undef $bad; # Dissect the parameters. $result = GetOptions ("split" => \$do_split, # No way to configure "no-" prefix instead of # "no"-prefix? "no-split" => \$do_not_split, "help" => \$do_help, "use-encoder-image=i" => \$use_encoder_img, "no-unzip" => \$no_unzip); $bad = "" # Already emitted by Getopt. if $result == 0; $bad = "" if !defined ($bad) && $do_help; $bad = "Can't have both --split and --no-split" if !defined ($bad) && $do_split == 1 && $do_not_split == 1; $do_split = 0 if $do_not_split == 1; $bad = "Only N=1 and N=2 allowed in --use-encoder-image=N" if (!defined ($bad) && $use_encoder_img != -1 && $use_encoder_img != 1 && $use_encoder_img != 2); bye ("Too many parameters\n") if $#ARGV > 2; bye << "EOF" $bad Usage: $0 --help or $0 [--split (default) | --no-split] [--use-encoder-image=1 | --use-encoder-image=2] [--no-unzip] [driver-location (default $default_readpath) or driver filename (with --no-unzip) [driver-destdir (default $default_destpath) | encoder-image (default $default_destpath/$default_encname) decoder-image (default $default_destpath/$default_decname)]] Examples: $0 $0 --use-encoder-image=2 pvr48xxx.exe $0 --no-split /mnt/cdrom /tmp/enc.img /tmp/dec.img EOF if defined $bad; $readpath = $#ARGV > -1 ? $ARGV[0] : $default_readpath; $destpath = $#ARGV > 0 ? $ARGV[1] : $default_destpath; if (-d $destpath) { bye ("Second parameter ($destpath) of three unexpectedly a directory") if $#ARGV > 1; bye ("Can't write to path for firmware, \"$destpath\"") unless -w $destpath; if ($do_split) { $encoder_path = "$destpath/$default_encname"; $decoder_path = "$destpath/$default_decname"; } else { $encoder_path = "$destpath/$default_encname.bin"; $decoder_path = "$destpath/$default_decname.bin"; } } else { bye ("Missing decoder path parameter (encoder path: $destpath)") if $#ARGV != 2; $encoder_path = $destpath; $decoder_path = $ARGV[2]; } # Did we get a directory for the driver? if (-d $readpath) { # Then find the driver somewhere there. $driverfile = `find $readpath -iname $packed_driver_name -print 2>/dev/null | head -1`; chomp $driverfile; bye ("Can't find \"$packed_driver_name\" in \"$readpath\"") unless $driverfile ne ""; } else { # Must be the path for the packed driver itself. $driverfile = $readpath; } bye ("\"$driverfile\" not accessible") unless -f $driverfile && -r $driverfile; if ($no_unzip) { $fw_driver_path = $readpath; } else { # That file is expected to be a self-extracting archive, though we # can just throw it to unzip. $tmpdir = (defined ($ENV{"TMPDIR"}) ? $ENV{"TMPDIR"} : "/tmp") . "/ivtvex.$$"; bye ("Can't create temporary directory $tmpdir") unless mkdir $tmpdir; $unzipcmd = "unzip -L -d $tmpdir $driverfile $fw_driver_name"; bye ("Can't perform \"$unzipcmd\"") unless defined `$unzipcmd 2>/dev/null`; $fw_driver_path = "$tmpdir/$fw_driver_name"; } # Read in the file. bye ("Can't open $fw_driver_path: $!") unless open FWFILE, "<$fw_driver_path"; bye ("Can't set binary mode for $fw_driver_path") unless binmode FWFILE; bye ("Can't read in $fw_driver_path") unless ((read FWFILE, $fwraw, -s "$fw_driver_path") == -s "$fw_driver_path"); bye ("Can't close $fw_driver_path") unless close FWFILE; # Find the special markers. # Aww, can't use index() on binary data (i.e. zero-terminated strings). # Can we assume there'll be no match on odd nybble boundaries? # Well, we'll treat that like "multiple images". $fwhex = unpack ("H*", $fwraw); $decoder_index = index ($fwhex, $decoder_magic) / 2; # No use adding --use-decoder-image willy-nilly-just-in-case. bye ("Confused: multiple decoder images found") if index ($fwhex, $decoder_magic, $decoder_index * 2 + 1) != -1; bye ("Can't find decoder image in $fw_driver_path") unless $decoder_index != -0.5; $decoder_image = substr ($fwraw, $decoder_index, 256 * 1024); $encoder_index = index ($fwhex, $encoder_magic) / 2; bye ("Can't find encoder image in $fw_driver_path") unless $encoder_index != -0.5; $next_encoder_index = index ($fwhex, $encoder_magic, $encoder_index * 2 + 1) / 2; if ($next_encoder_index != -0.5) { bye ("Confused: at least two encoder images found\n" . " but no --use-encoder-image=N (N=1,2) given") if $use_encoder_img == -1; $encoder_index = $next_encoder_index if ($use_encoder_img == 2); # What, you really think there should be a *loop* for N? $next_encoder_index = index ($fwhex, $encoder_magic, $next_encoder_index * 2 + 1); bye ("Confused: three encoder images found. What's going on here?") if $next_encoder_index != -1; } else { bye ("Confused: only one encoder image found\n" . " but --use-encoder-image=$use_encoder_img specified") if $use_encoder_img != -1; } $encoder_image = substr ($fwraw, $encoder_index, 256 * 1024); # Write out the images to the awaiting files and we're done. if ($do_split) { bye ("Can't open encoder image file $encoder_path-1.bin") unless open ENCFILE, ">$encoder_path-1.bin"; bye ("Can't set binary mode for $fw_driver_path-1.bin") unless binmode ENCFILE; bye ("Can't write encoder image to $encoder_path-1.bin") unless (syswrite (ENCFILE, $encoder_image, length ($encoder_image) / 2) == length ($encoder_image) / 2); bye ("Can't close encoder image file $encoder_path-1.bin") unless close ENCFILE; bye ("Can't open encoder image file $encoder_path-2.bin") unless open ENCFILE, ">$encoder_path-2.bin"; bye ("Can't set binary mode for $fw_driver_path-2.bin") unless binmode ENCFILE; bye ("Can't write encoder image to $encoder_path-2.bin") unless (syswrite (ENCFILE, $encoder_image, length ($encoder_image) / 2, length ($encoder_image) / 2) == length ($encoder_image) / 2); bye ("Can't close encoder image file $encoder_path-2.bin") unless close ENCFILE; bye ("Can't open decoder image file $decoder_path-1.bin") unless open DECFILE, ">$decoder_path-1.bin"; bye ("Can't set binary mode for $fw_driver_path-1.bin") unless binmode DECFILE; bye ("Can't write decoder image to $decoder_path-1.bin") unless (syswrite (DECFILE, $decoder_image, length ($decoder_image) / 2) == length ($decoder_image) / 2); bye ("Can't close decoder image file $decoder_path-1.bin") unless close DECFILE; bye ("Can't open decoder image file $decoder_path-2.bin") unless open DECFILE, ">$decoder_path-2.bin"; bye ("Can't set binary mode for $fw_driver_path-2.bin") unless binmode DECFILE; bye ("Can't write decoder image to $decoder_path-2.bin") unless (syswrite (DECFILE, $decoder_image, length ($decoder_image) / 2, length ($decoder_image) / 2) == length ($decoder_image) / 2); bye ("Can't close decoder image file $decoder_path-2.bin") unless close DECFILE; } else { bye ("Can't open encoder image file $encoder_path") unless open ENCFILE, ">$encoder_path"; bye ("Can't set binary mode for $fw_driver_path") unless binmode ENCFILE; bye ("Can't write encoder image to $encoder_path") unless ((syswrite ENCFILE, $encoder_image) == length ($encoder_image)); bye ("Can't close encoder image file $encoder_path") unless close ENCFILE; bye ("Can't open decoder image file $decoder_path") unless open DECFILE, ">$decoder_path"; bye ("Can't set binary mode for $fw_driver_path") unless binmode DECFILE; bye ("Can't write decoder image to $decoder_path") unless ((syswrite DECFILE, $decoder_image) == length ($decoder_image)); bye ("Can't close decoder image file $decoder_path") unless close DECFILE; } bye (""); # Graceful exit, hopefully. sub bye { $args = join ("", @_); `rm -rf $tmpdir 2>/dev/null` if defined $tmpdir; die ("$0: $args\n") if $args ne ""; exit 0; } ivtv-utils-1.4.1/utils/encoder.c0000664000076400007640000006002311355717530015260 0ustar andyandy/* Copyright (C) 2004 Chris Kennedy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include /* Uses _GNU_SOURCE to define getsubopt in stdlib.h */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define __user #include #include "ivtv.h" #include "ivtv-functions.h" #include "encoder.h" /* defined in compile args */ /* #define VIDEO_PORT 0 */ void cleanup(int); void __cleanup(void); void stop_encoder(int); void index_t(void); void *index_thread(void *); int mindex(char *output_file, char *index_file, char *bstatus); int streamfd(int fdout, int fdin, int count); int writeall(int fd, char *buf, int count); int chann(int fd, int chan_num); int chanf(int fd, int frequency); void usage(void); int splice(unsigned char *, int, int); #define SPLICE_START 1 #define SPLICE_END 2 #define GOP_COUNTER 3 #define GOP_COUNTER_START 4 #define VIDEO_DEVICE "/dev/video" #define START_BYTES 0 #define START_GOP 0 /* Encoder Settings */ #define VIDEO_INPUT 0 #define BRIGHTNESS 128 #define CONTRAST 64 #define SATURATION 64 #define HUE 0 #define ASPECT 2 #define BMODE 0 #define BRATE 8000000 #define BPEAK 12000000 #define STREAM 0 #define AUDIO 201 /* 0xc9(201) = 256k 48000khz, 0xe9(233) = 384k 48000khz */ #define DNRMODE 3 #define DNRTYPE 3 #define DNRSPAT 0 #define DNRTEMP 0 #define PDOWN 0 #define FRATE 0 #define FPGOP 15 #define BFRAMES 3 #define GOPCL 1 int settings[18] = { ASPECT, BMODE, BRATE, BPEAK, STREAM, AUDIO, DNRMODE, DNRTYPE, DNRSPAT, DNRTEMP, PDOWN, BRIGHTNESS, CONTRAST, SATURATION, HUE, VIDEO_INPUT, FRATE, FPGOP }; #define CAP_LAST_GOP 1 #define USE_STOPCAP #define ELOCK "/tmp/en_lock." #define ELOCKLINK "/tmp/en_lock_l." #define BSTATUS "/tmp/" //#define MAX_INPUT_LINE 1572864 //#define MAX_INPUT_LINE 256000 //#define MAX_INPUT_LINE 16384 #define MAX_INPUT_LINE 32768 #define SHOW_LINE_COUNT 0 #define VERBOSE 1 #define DEBUG 0 /* GOP Splicer/Timer Variables */ #define VID_START 0x000001e0 #define VID_END 0x000001ef #define SEQ_START 0x000001b3 #define SEQ_END 0x000001b7 #define GOP_START 0x000001b8 #define PICTURE_START 0x00000100 #define SLICE_MIN 0x00000101 #define SLICE_MAX 0x000001af char *lock_link = NULL; int fdout = -1, fdin = -1, fd = -1; int video_port = VIDEO_PORT; char *video_device = NULL, *elock = NULL; /* GOP Splicer/Timer Variables */ int startpos = 0; int laststartpos = 0; int gopset = 0; int gopcount = 0; int firstgoppos = 0; int framesRead = 0; int keyframedist = 0; int lastKey = 0; unsigned char prvpkt[3]; int start_write = 1; int stop_gop = 0; int end_stream = 0; unsigned long total_bytes = 0; unsigned long bytes; /* Threading stuff */ pthread_t index_thread_tid; int chan_num = 0; int chan_freq = 0; char *output_file = NULL; char *index_file = NULL; char *bstatus = NULL; int main(int argc, char *argv[]) { unsigned char *line = NULL; int strsize, i, j; int seconds = 0; FILE *lck = NULL; pid_t pid; time_t now; int launch_thread = 0; int setup_only = 0; int stdout_stream = 0; /* GOP Splicer/Timer Variables */ prvpkt[0] = '\0'; prvpkt[2] = '\0'; prvpkt[3] = '\0'; startpos = 0; laststartpos = 0; gopset = 0; gopcount = 0; firstgoppos = 0; framesRead = 0; keyframedist = 0; lastKey = 0; /* get current UNIX time and PID */ time(&now); pid = getpid(); /* Allocate memory for Strings */ lock_link = malloc(25 + 7); if (lock_link == NULL) exit(1); snprintf(lock_link, 25 + 7, "%s%d", ELOCKLINK, pid); signal(SIGPIPE, cleanup); signal(SIGHUP, cleanup); signal(SIGTERM, cleanup); signal(SIGUSR1, cleanup); signal(SIGINT, cleanup); signal(SIGALRM, stop_encoder); atexit(__cleanup); /*******************/ /* Check Arguments */ /*******************/ if (argc > 1) { for (i = 1; argv[i] && (i <= argc); i++) { if ((strncmp(argv[i], "-", 1) == 0 && (strlen(argv[i]) == 1))) { if (i == (argc - 1)) { stdout_stream = 1; fdout = 1; output_file = "stdout"; } else exit(1); } else if ((strncmp(argv[i], "-", 1) == 0) && (argv[i][1] == '\0')) continue; else if (strncmp(argv[i], "-input", 3) == 0) { /* Input */ char *var = NULL; for (j = 0; argv[i + 1][j] != '\0'; j++) { if (isdigit(argv[i + 1][j]) == 0) { /* Bad Argument Given */ fprintf(stderr, "Input: ERROR: bad option! %s\n", argv[i]); usage(); exit(1); } } strsize = strlen(argv[i + 1]); var = malloc(strsize + 1); if (var == NULL) continue; strncpy(var, argv[i + 1], strsize + 1); settings[15] = (int)atoi(var); i++; continue; } else if (strncmp(argv[i], "-hue", 3) == 0) { /* Hue */ char *var = NULL; for (j = 0; argv[i + 1][j] != '\0'; j++) { if (isdigit(argv[i + 1][j]) == 0) { /* Bad Argument Given */ fprintf(stderr, "Hue: ERROR: bad option! %s\n", argv[i]); usage(); exit(1); } } strsize = strlen(argv[i + 1]); var = malloc(strsize + 1); if (var == NULL) continue; strncpy(var, argv[i + 1], strsize + 1); settings[14] = (int)atoi(var); i++; continue; } else if (strncmp(argv[i], "-saturation", 10) == 0) { /* Saturation */ char *var = NULL; for (j = 0; argv[i + 1][j] != '\0'; j++) { if (isdigit(argv[i + 1][j]) == 0) { /* Bad Argument Given */ fprintf(stderr, "Saturation: ERROR: bad option! %s\n", argv[i]); usage(); exit(1); } } strsize = strlen(argv[i + 1]); var = malloc(strsize + 1); if (var == NULL) continue; strncpy(var, argv[i + 1], strsize + 1); settings[13] = (int)atoi(var); i++; continue; } else if (strncmp(argv[i], "-contrast", 8) == 0) { /* Contrast */ char *var = NULL; for (j = 0; argv[i + 1][j] != '\0'; j++) { if (isdigit(argv[i + 1][j]) == 0) { /* Bad Argument Given */ fprintf(stderr, "Contrast: ERROR: bad option! %s\n", argv[i]); usage(); exit(1); } } strsize = strlen(argv[i + 1]); var = malloc(strsize + 1); if (var == NULL) continue; strncpy(var, argv[i + 1], strsize + 1); settings[12] = (int)atoi(var); i++; continue; } else if (strncmp(argv[i], "-brightness", 10) == 0) { /* Brightness */ char *var = NULL; for (j = 0; argv[i + 1][j] != '\0'; j++) { if (isdigit(argv[i + 1][j]) == 0) { /* Bad Argument Given */ fprintf(stderr, "Brightness: ERROR: bad option! %s\n", argv[i]); usage(); exit(1); } } strsize = strlen(argv[i + 1]); var = malloc(strsize + 1); if (var == NULL) continue; strncpy(var, argv[i + 1], strsize + 1); settings[11] = (int)atoi(var); i++; continue; } else if (strncmp(argv[i], "-pulldown", 8) == 0) { /* Pulldown */ char *var = NULL; for (j = 0; argv[i + 1][j] != '\0'; j++) { if (isdigit(argv[i + 1][j]) == 0) { /* Bad Argument Given */ fprintf(stderr, "Pulldown: ERROR: bad option! %s\n", argv[i]); usage(); exit(1); } } strsize = strlen(argv[i + 1]); var = malloc(strsize + 1); if (var == NULL) continue; strncpy(var, argv[i + 1], strsize + 1); settings[10] = (int)atoi(var); i++; continue; } else if (strncmp(argv[i], "-dnrtemp", 7) == 0) { /* DNR Temporal */ char *var = NULL; for (j = 0; argv[i + 1][j] != '\0'; j++) { if (isdigit(argv[i + 1][j]) == 0) { /* Bad Argument Given */ fprintf(stderr, "DNR Temporal: ERROR: bad option! %s\n", argv[i]); usage(); exit(1); } } strsize = strlen(argv[i + 1]); var = malloc(strsize + 1); if (var == NULL) continue; strncpy(var, argv[i + 1], strsize + 1); settings[9] = (int)atoi(var); i++; continue; } else if (strncmp(argv[i], "-dnrspat", 7) == 0) { /* DNR Spatial */ char *var = NULL; for (j = 0; argv[i + 1][j] != '\0'; j++) { if (isdigit(argv[i + 1][j]) == 0) { /* Bad Argument Given */ fprintf(stderr, "DNR Spatial: ERROR: bad option! %s\n", argv[i]); usage(); exit(1); } } strsize = strlen(argv[i + 1]); var = malloc(strsize + 1); if (var == NULL) continue; strncpy(var, argv[i + 1], strsize + 1); settings[8] = (int)atoi(var); i++; continue; } else if (strncmp(argv[i], "-dnrtype", 7) == 0) { /* DNR Type */ char *var = NULL; for (j = 0; argv[i + 1][j] != '\0'; j++) { if (isdigit(argv[i + 1][j]) == 0) { /* Bad Argument Given */ fprintf(stderr, "DNR Type: ERROR: bad option! %s\n", argv[i]); usage(); exit(1); } } strsize = strlen(argv[i + 1]); var = malloc(strsize + 1); if (var == NULL) continue; strncpy(var, argv[i + 1], strsize + 1); settings[7] = (int)atoi(var); i++; continue; } else if (strncmp(argv[i], "-dnrmode", 7) == 0) { /* DNR Mode */ char *var = NULL; for (j = 0; argv[i + 1][j] != '\0'; j++) { if (isdigit(argv[i + 1][j]) == 0) { /* Bad Argument Given */ fprintf(stderr, "DNR Mode: ERROR: bad option! %s\n", argv[i]); usage(); exit(1); } } strsize = strlen(argv[i + 1]); var = malloc(strsize + 1); if (var == NULL) continue; strncpy(var, argv[i + 1], strsize + 1); settings[6] = (int)atoi(var); i++; continue; } else if (strncmp(argv[i], "-audio", 5) == 0) { /* Audio Bitmask */ char *var = NULL; for (j = 0; argv[i + 1][j] != '\0'; j++) { if (isdigit(argv[i + 1][j]) == 0) { /* Bad Argument Given */ fprintf(stderr, "Audio Bitmask: ERROR: bad option! %s\n", argv[i]); usage(); exit(1); } } strsize = strlen(argv[i + 1]); var = malloc(strsize + 1); if (var == NULL) continue; strncpy(var, argv[i + 1], strsize + 1); settings[5] = (int)atoi(var); i++; continue; } else if (strncmp(argv[i], "-stream", 6) == 0) { /* Stream Type */ char *var = NULL; for (j = 0; argv[i + 1][j] != '\0'; j++) { if (isdigit(argv[i + 1][j]) == 0) { /* Bad Argument Given */ fprintf(stderr, "Stream Type: ERROR: bad option! %s\n", argv[i]); usage(); exit(1); } } strsize = strlen(argv[i + 1]); var = malloc(strsize + 1); if (var == NULL) continue; strncpy(var, argv[i + 1], strsize + 1); settings[4] = (int)atoi(var); i++; continue; } else if (strncmp(argv[i], "-bpeak", 5) == 0) { /* Bitrate Peak */ char *var = NULL; for (j = 0; argv[i + 1][j] != '\0'; j++) { if (isdigit(argv[i + 1][j]) == 0) { /* Bad Argument Given */ fprintf(stderr, "Bitrate: ERROR: bad option! %s\n", argv[i]); usage(); exit(1); } } strsize = strlen(argv[i + 1]); var = malloc(strsize + 1); if (var == NULL) continue; strncpy(var, argv[i + 1], strsize + 1); settings[3] = (int)atoi(var); i++; continue; } else if (strncmp(argv[i], "-brate", 5) == 0) { /* Bitrate */ char *var = NULL; for (j = 0; argv[i + 1][j] != '\0'; j++) { if (isdigit(argv[i + 1][j]) == 0) { /* Bad Argument Given */ fprintf(stderr, "Bitrate: ERROR: bad option! %s\n", argv[i]); usage(); exit(1); } } strsize = strlen(argv[i + 1]); var = malloc(strsize + 1); if (var == NULL) continue; strncpy(var, argv[i + 1], strsize + 1); settings[2] = (int)atoi(var); i++; continue; } else if (strncmp(argv[i], "-bmode", 5) == 0) { /* Bitrate Mode */ char *var = NULL; for (j = 0; argv[i + 1][j] != '\0'; j++) { if (isdigit(argv[i + 1][j]) == 0) { /* Bad Argument Given */ fprintf(stderr, "Bitrate Mode: ERROR: bad option! %s\n", argv[i]); usage(); exit(1); } } strsize = strlen(argv[i + 1]); var = malloc(strsize + 1); if (var == NULL) continue; strncpy(var, argv[i + 1], strsize + 1); settings[1] = (int)atoi(var); i++; continue; } else if (strncmp(argv[i], "-aspect", 6) == 0) { /* Aspect Ratio */ char *var = NULL; for (j = 0; argv[i + 1][j] != '\0'; j++) { if (isdigit(argv[i + 1][j]) == 0) { /* Bad Argument Given */ fprintf(stderr, "Aspect Ratio: ERROR: bad option! %s\n", argv[i]); usage(); exit(1); } } strsize = strlen(argv[i + 1]); var = malloc(strsize + 1); if (var == NULL) continue; strncpy(var, argv[i + 1], strsize + 1); settings[0] = (int)atoi(var); i++; continue; } else if (strncmp(argv[i], "-frate", 6) == 0) { /* Frame Rate */ char *var = NULL; for (j = 0; argv[i + 1][j] != '\0'; j++) { if (isdigit(argv[i + 1][j]) == 0) { /* Bad Argument Given */ fprintf(stderr, "Frame Rate: ERROR: bad option! %s\n", argv[i]); usage(); exit(1); } } strsize = strlen(argv[i + 1]); var = malloc(strsize + 1); if (var == NULL) continue; strncpy(var, argv[i + 1], strsize + 1); settings[16] = (int)atoi(var); i++; continue; } else if (strncmp(argv[i], "-fpgop", 6) == 0) { /* Frames per GOP */ char *var = NULL; for (j = 0; argv[i + 1][j] != '\0'; j++) { if (isdigit(argv[i + 1][j]) == 0) { /* Bad Argument Given */ fprintf(stderr, "Frames per GOP: ERROR: bad option! %s\n", argv[i]); usage(); exit(1); } } strsize = strlen(argv[i + 1]); var = malloc(strsize + 1); if (var == NULL) continue; strncpy(var, argv[i + 1], strsize + 1); settings[17] = (int)atoi(var); i++; continue; } else if (strncmp(argv[i], "-vport", 6) == 0) { /* Video Device */ char *var = NULL; for (j = 0; argv[i + 1][j] != '\0'; j++) { if (isdigit(argv[i + 1][j]) == 0) { /* Bad Argument Given */ fprintf(stderr, "Video Device: ERROR: bad option! %s\n", argv[i]); usage(); exit(1); } } strsize = strlen(argv[i + 1]); var = malloc(strsize + 1); if (var == NULL) continue; strncpy(var, argv[i + 1], strsize + 1); video_port = (int)atoi(var); i++; continue; } else if (strncmp(argv[i], "-c", 2) == 0) { /* Tune Channel */ char *station = NULL; for (j = 0; argv[i + 1][j] != '\0'; j++) { if (isdigit(argv[i + 1][j]) == 0) { /* Bad Argument Given */ fprintf(stderr, "Tune Channel: ERROR: bad option! %s\n", argv[i]); usage(); exit(1); } } strsize = strlen(argv[i + 1]); station = malloc(strsize + 1); if (station == NULL) continue; strncpy(station, argv[i + 1], strsize + 1); chan_num = (int)atoi(station); i++; continue; } else if (strncmp(argv[i], "-f", 2) == 0) { /* Tune Frequency */ char *freqstr = NULL; for (j = 0; argv[i + 1][j] != '\0'; j++) { if (isdigit(argv[i + 1][j]) == 0) { /* Bad Argument Given */ fprintf(stderr, "Tune Frequency: ERROR: bad option! %s\n", argv[i]); usage(); exit(1); } } strsize = strlen(argv[i + 1]); freqstr = malloc(strsize + 1); if (freqstr == NULL) continue; strncpy(freqstr, argv[i + 1], strsize + 1); chan_freq = (int)atoi(freqstr); i++; continue; } else if (strncmp(argv[i], "/", 1) == 0 && !stdout_stream) { /* File location */ strsize = strlen(argv[i]); output_file = malloc(strsize + 1); index_file = malloc(strsize + 6 + 1); if (output_file == NULL || index_file == NULL) continue; strncpy(output_file, argv[i], strsize + 1); snprintf(index_file, (strsize + 6 + 1), "%s.index", argv[i]); continue; } else if (strncmp(argv[i], "-s", 2) == 0) { /* Setup Encoder */ setup_only = 1; continue; } else { /* Recording Time */ for (j = 0; argv[i][j] != '\0'; j++) { if (isdigit(argv[i][j]) == 0) { /* Bad Argument Given */ fprintf(stderr, "Rec Time: ERROR: bad option! %s\n", argv[i]); usage(); exit(1); } } seconds = (int)atoi(argv[i]); } } } else { usage(); exit(1); } elock = malloc(23 + 7); if (elock == NULL) exit(1); snprintf(elock, 23 + 7, "%s%d", ELOCK, video_port); video_device = malloc(24 + 1); if (video_device == NULL) exit(1); snprintf(video_device, 24 + 1, "%s%d", VIDEO_DEVICE, video_port); bstatus = malloc(29 + 1); if (bstatus == NULL) exit(1); snprintf(bstatus, 29 + 1, "%s%d.status", BSTATUS, video_port); /* Printout What we will do */ if (VERBOSE && setup_only == 0) fprintf(stderr, "\n(%d) Encoding for %d Seconds to %s\n", video_port, seconds, output_file); /* Lock Video Input */ lck = fopen(lock_link, "w"); if (lck == NULL) return 1; fprintf(lck, "%d", pid); if (link(lock_link, elock) != 0) { fclose(lck); unlink(lock_link); return 1; } else fclose(lck); /* Setup Environment */ umask(022); /* Allocate input line */ line = malloc(MAX_INPUT_LINE + 1); if (line == NULL) exit(1); /* Open Video Input */ while ((fdin = open(video_device, O_RDONLY)) < 0) { fprintf(stderr, "Failed to open %s: %s\n", video_device, strerror(errno)); sleep(1); } /* Tune to a TV Frequency */ if (chan_freq > 0) { if (VERBOSE) fprintf(stderr, "(%d) Tuning to Frequency %d\n", video_port, chan_freq); chanf(fdin, chan_freq); } /* Tune to a TV Channel */ else if (chan_num > 0) { if (VERBOSE) fprintf(stderr, "(%d) Tuning to Channel %d\n", video_port, chan_num); chann(fdin, chan_num); } if (setup_only == 1) { if (VERBOSE) fprintf(stderr, "Setting up Encoder %d\n", video_port); setup_encoder(fdin, settings); ivtv_api_enc_endgop(fdin, CAP_LAST_GOP); cleanup(0); } /* setup video device */ setup_encoder(fdin, settings); /* End Encoding at GOP Ending Call 0=StopNOW, 1=GOPwait */ ivtv_api_enc_endgop(fdin, CAP_LAST_GOP); /* Open Mpeg Output */ if (!stdout_stream) { if ((fdout = open(output_file, O_CREAT | O_WRONLY)) < 0) { fprintf(stderr, "Failed to open %s: %s\n", output_file, strerror(errno)); exit(1); } chmod(output_file, 0644); } /* Time the Recording */ #if 0 t_stop.it_interval.tv_sec = 0; t_stop.it_interval.tv_usec = 1; t_stop.it_value.tv_sec = 0; t_stop.it_value.tv_usec = (seconds * 1000000); setitimer(ITIMER_REAL, &t_stop, 0); #endif alarm(seconds); while (start_write) { if (stop_gop) { stop_gop = 0; ivtv_api_enc_stop(fdin); end_stream = 1; signal(SIGALRM, SIG_IGN); } bytes = streamfd(fdout, fdin, MAX_INPUT_LINE); if (!bytes && end_stream) break; if (bytes > 0) total_bytes = total_bytes + bytes; else fprintf(stderr, "(%d) %lu received from encoder!!!\n", video_port, bytes); if (SHOW_LINE_COUNT) fprintf(stderr, "(%d) Wrote %lu bytes total: %lu\n", video_port, bytes, total_bytes); if (launch_thread == 0 && !stdout_stream) { launch_thread = 1; index_t(); } } __cleanup(); exit(0); } void cleanup(int signal) { __cleanup(); exit(0); } void __cleanup(void) { if (fdin > 0) close(fdin); if (fdout > 0) close(fdout); unlink(lock_link); unlink(elock); } void stop_encoder(int signal) { #ifdef USE_STOPCAP fprintf(stderr, "Stop signal for Encoding received, bytes %lu\n", bytes); stop_gop = 1; #else start_write = 0; cleanup(signal); #endif } /* Code borrowed from MythTV */ int splice(unsigned char *buf, int len, int mode) { unsigned char *bufptr = buf; unsigned int state = 0xFFFFFFFF, v = 0; int prvcount = -1; int count = 0; int lastgop = 0; int lastpic = 0; while (bufptr < buf + len) { if (++prvcount < 3) v = prvpkt[prvcount]; else { v = *bufptr++; count++; } if (state == 0x000001) { state = ((state << 8) | v) & 0xFFFFFF; if (state >= SLICE_MIN && state <= SLICE_MAX) { continue; } if (state >= VID_START && state <= VID_END) { laststartpos = (bufptr - buf) + startpos - 4; continue; } switch (state) { case SEQ_START: { if (DEBUG) fprintf(stderr, "SeqHeader mode %d lastgop %d bytes %d\n", mode, lastgop, count); /*if(count >= 4 && mode == SPLICE_START) { if(count >= 4) return count - 4; } */ break; } case SEQ_END: { if (DEBUG) fprintf(stderr, "SeqEnd mode %d lastgop %d bytes %d\n", mode, lastgop, count); if (count >= 1 && mode == SPLICE_END) { if (count >= 1) return count - 4; } break; } case GOP_START: { gopcount++; lastgop = count; if (DEBUG) fprintf(stderr, "GOPcount %d mode %d lastgop %d bytes %d\n", gopcount, mode, lastgop, count); if (mode == SPLICE_START) { if (count >= 1) return count - 1; } else if (mode == GOP_COUNTER_START) { if (count >= 1 && gopcount >= START_GOP) return count - 1; } break; } case PICTURE_START: { framesRead++; lastpic = count; if (DEBUG) fprintf(stderr, "Picture Start frames %d bytes %d\n", framesRead, count); break; } default: break; } continue; } state = ((state << 8) | v) & 0xFFFFFF; } memcpy(prvpkt, buf + len - 3, 3); if (mode == GOP_COUNTER) return gopcount - 1; else if (mode == SPLICE_END) { if (lastgop > 0) return lastgop; else return -1; } else return count; } int writeall(int fd, char *buf, int count) { int origcount = count; /* Total Bytes Decoded */ total_bytes = total_bytes + count; while (count > 0) { int n = write(fd, buf, count); if (n < 0) return n; count -= n; buf += n; } return origcount; } int streamfd(int fdout, int fdin, int count) { static const int bufsize = 262144; char buf[bufsize]; int remaining = count; count = 0; while (remaining > 0) { int k; int n = (remaining < bufsize) ? remaining : bufsize; n = read(fdin, buf, n); if (n <= 0) return n; k = writeall(fdout, buf, n); if (k < 0) return k; assert(k == n); remaining -= n; count += n; } return count; } void index_t(void) { pthread_create(&index_thread_tid, NULL, index_thread, (void *)(long)fdout); pthread_detach(index_thread_tid); return; } /* Index Thread */ void *index_thread(void *arg) { mindex(output_file, index_file, bstatus); if (VERBOSE) fprintf(stderr, "(%d) index_loop stopped on byte %lu\n", video_port, total_bytes); return 0; } void usage(void) { fprintf(stderr, "Usage: encoder [-s] [-c chann|-f freq] [seconds] [mpegfile]\n\ [-vport N]\tVideo Device Port: 0-n\n\ [-aspect N]\tAspect Ratio: 1-4\n\ [-bmode N]\tBitrate Mode: 0=var 1=const\n\ [-brate N]\tBitrate: 1000000-15000000\n\ [-bpeak N]\tPeak Bitrate: 1000000-16000000\n\ [-stream N]\tStream Type: 0-14\n\ [-frate N]\tFrame Rate: 0=30fps or 1=25fps\n\ [-fpgop N]\tGOP size\n\ [-audio N]\tAudio Bitmask in Decimal: 0-255 bitmask\n\ [-dnrmode N]\tDNR Mode: 0-3\n\ [-dnrtype N]\tDNR Type: 0-3\n\ [-dnrspat N]\tDNR Spatial: 0-16\n\ [-dnrtemp N]\tDNR Tempporal: 0-32\n\ [-pulldown N]\tPulldown: 0-1\n\ [-brightness N]\t0-255\n\ [-contrast N]\t0-127\n\ [-saturation N]\t0-127\n\ [-hue N]\t-128-128\n\ [-input N]\tInput Port: 0-8\n"); } ivtv-utils-1.4.1/utils/ivtv-ctl.c0000664000076400007640000004446211355717530015422 0ustar andyandy/* Copyright (C) 2003-2004 Kevin Thayer Cleanup and VBI and audio in/out options: Copyright (C) 2004 Hans Verkuil This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include /* Uses _GNU_SOURCE to define getsubopt in stdlib.h */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* copied from ivtv-driver.h */ #define IVTV_DBGFLG_WARN (1 << 0) #define IVTV_DBGFLG_INFO (1 << 1) #define IVTV_DBGFLG_MB (1 << 2) #define IVTV_DBGFLG_IOCTL (1 << 3) #define IVTV_DBGFLG_FILE (1 << 4) #define IVTV_DBGFLG_DMA (1 << 5) #define IVTV_DBGFLG_IRQ (1 << 6) #define IVTV_DBGFLG_DEC (1 << 7) #define IVTV_DBGFLG_YUV (1 << 8) #define IVTV_DBGFLG_I2C (1 << 9) /* Flag to turn on high volume debugging */ #define IVTV_DBGFLG_HIGHVOL (1 << 10) /* Internals copied from media/v4l2-common.h */ struct v4l2_routing { __u32 input; __u32 output; }; #define VIDIOC_INT_S_AUDIO_ROUTING _IOW('d', 109, struct v4l2_routing) #define VIDIOC_INT_RESET _IOW('d', 102, __u32) #include /* GPIO */ #define IVTV_REG_GPIO_IN_OFFSET (0x9008 + 0x02000000) #define IVTV_REG_GPIO_OUT_OFFSET (0x900c + 0x02000000) #define IVTV_REG_GPIO_DIR_OFFSET (0x9020 + 0x02000000) /* Options */ enum Option { OptSetDebugLevel = 'D', OptSetDevice = 'd', OptGetDebugLevel = 'e', OptHelp = 'h', OptSetGPIO = 'i', OptListGPIO = 'I', OptPassThrough = 'K', OptFrameSync = 'k', OptSetAudioRoute = 'v', OptReset = 128, OptSetYuvMode, OptGetYuvMode, OptSetAudioMute, OptSetStereoMode, OptSetBilingualMode, OptLast = 256 }; static char options[OptLast]; static int app_result; static struct option long_options[] = { /* Please keep in alphabetical order of the short option. That makes it easier to see which options are still free. */ {"set-debug", required_argument, 0, OptSetDebugLevel}, {"device", required_argument, 0, OptSetDevice}, {"get-debug", no_argument, 0, OptGetDebugLevel}, {"help", no_argument, 0, OptHelp}, {"set-gpio", required_argument, 0, OptSetGPIO}, {"list-gpio", no_argument, 0, OptListGPIO}, {"passthrough", required_argument, 0, OptPassThrough}, {"sync", no_argument, 0, OptFrameSync}, {"audio-route", required_argument, 0, OptSetAudioRoute}, {"reset", required_argument, 0, OptReset}, {"get-yuv-mode", no_argument, 0, OptGetYuvMode}, {"set-yuv-mode", required_argument, 0, OptSetYuvMode}, {"set-audio-mute", required_argument, 0, OptSetAudioMute}, {"set-stereo-mode", required_argument, 0, OptSetStereoMode}, {"set-bilingual-mode", required_argument, 0, OptSetBilingualMode}, {0, 0, 0, 0} }; static void usage(void) { printf("Usage:\n"); printf(" -d, --device use device instead of /dev/video0\n"); printf(" -h, --help display this help message\n"); printf(" -K, --passthrough \n"); printf(" set passthrough mode: 1 = on, 0 = off [IVTV_IOC_PASSTHROUGH]\n"); printf(" --get-yuv-mode display the current yuv mode\n"); printf(" --set-yuv-mode mode=\n"); printf(" set the current yuv mode:\n"); printf(" mode 0: interlaced (top transmitted first)\n"); printf(" mode 1: interlaced (bottom transmitted first)\n"); printf(" mode 2: progressive\n"); printf(" mode 3: auto\n"); printf(" --set-audio-mute \n"); printf(" 0=enable audio during 1.5x and 0.5x playback\n"); printf(" 1=mute audio during 1.5x and 0.5x playback\n"); printf(" --set-stereo-mode \n"); printf(" mode 0: playback stereo as stereo\n"); printf(" mode 1: playback left stereo channel as mono\n"); printf(" mode 2: playback right stereo channel as mono\n"); printf(" mode 3: playback stereo as mono\n"); printf(" mode 4: playback stereo as swapped stereo\n"); printf(" --set-bilingual-mode \n"); printf(" mode 0: playback bilingual as stereo\n"); printf(" mode 1: playback left bilingual channel as mono\n"); printf(" mode 2: playback right bilingual channel as mono\n"); printf(" mode 3: playback bilingual as mono\n"); printf(" mode 4: playback bilingual as swapped stereo\n"); printf(" --reset reset the infrared receiver (1) or digitizer (2) [VIDIOC_INT_RESET]\n"); printf("\n"); printf("Expert options:\n"); printf(" -D, --set-debug \n"); printf(" set the module debug variable\n"); printf(" 1/0x0001: warning\n"); printf(" 2/0x0002: info\n"); printf(" 4/0x0004: mailbox\n"); printf(" 8/0x0008: ioctl\n"); printf(" 16/0x0010: file\n"); printf(" 32/0x0020: dma\n"); printf(" 64/0x0040: irq\n"); printf(" 128/0x0080: decoder\n"); printf(" 256/0x0100: yuv\n"); printf(" 512/0x0200: i2c\n"); printf(" 1024/0x0400: high volume\n"); printf(" -e, --get-debug query the module debug variable\n"); printf(" -I, --list-gpio\n"); printf(" show GPIO input/direction/output bits\n"); printf(" -i, --set-gpio [dir=,]val=\n"); printf(" set GPIO direction bits to and set output to \n"); printf(" -k, --sync test vsync's capabilities [VIDEO_GET_EVENT]\n"); printf(" -v, --audio-route=input=,output=\n"); printf(" set the audio input/output routing [VIDIOC_INT_S_AUDIO_ROUTING]\n"); exit(0); } static char *pts_to_string(char *str, unsigned long pts, float fps) { static char buf[256]; int hours, minutes, seconds, fracsec; int frame; char *p = (str) ? str : buf; static const int MPEG_CLOCK_FREQ = 90000; seconds = pts / MPEG_CLOCK_FREQ; fracsec = pts % MPEG_CLOCK_FREQ; minutes = seconds / 60; seconds = seconds % 60; hours = minutes / 60; minutes = minutes % 60; frame = (int)ceilf(((float)fracsec / (float)MPEG_CLOCK_FREQ) * fps); snprintf(p, sizeof(buf), "%d:%02d:%02d:%d", hours, minutes, seconds, frame); return p; } static void print_debug_mask(int mask) { #define MASK_OR_NOTHING (mask ? " | " : "") if (mask & IVTV_DBGFLG_WARN) { mask &= ~IVTV_DBGFLG_WARN; printf("IVTV_DBGFLG_WARN%s", MASK_OR_NOTHING); } if (mask & IVTV_DBGFLG_INFO) { mask &= ~IVTV_DBGFLG_INFO; printf("IVTV_DBGFLG_INFO%s", MASK_OR_NOTHING); } if (mask & IVTV_DBGFLG_MB) { mask &= ~IVTV_DBGFLG_MB; printf("IVTV_DBGFLG_MB%s", MASK_OR_NOTHING); } if (mask & IVTV_DBGFLG_DMA) { mask &= ~IVTV_DBGFLG_DMA; printf("IVTV_DBGFLG_DMA%s", MASK_OR_NOTHING); } if (mask & IVTV_DBGFLG_IOCTL) { mask &= ~IVTV_DBGFLG_IOCTL; printf("IVTV_DBGFLG_IOCTL%s", MASK_OR_NOTHING); } if (mask & IVTV_DBGFLG_FILE) { mask &= ~IVTV_DBGFLG_FILE; printf("IVTV_DBGFLG_FILE%s", MASK_OR_NOTHING); } if (mask & IVTV_DBGFLG_I2C) { mask &= ~IVTV_DBGFLG_I2C; printf("IVTV_DBGFLG_I2C%s", MASK_OR_NOTHING); } if (mask & IVTV_DBGFLG_IRQ) { mask &= ~IVTV_DBGFLG_IRQ; printf("IVTV_DBGFLG_IRQ%s", MASK_OR_NOTHING); } if (mask & IVTV_DBGFLG_DEC) { mask &= ~IVTV_DBGFLG_DEC; printf("IVTV_DBGFLG_DEC%s", MASK_OR_NOTHING); } if (mask & IVTV_DBGFLG_YUV) { mask &= ~IVTV_DBGFLG_YUV; printf("IVTV_DBGFLG_YUV%s", MASK_OR_NOTHING); } if (mask & IVTV_DBGFLG_HIGHVOL) { mask &= ~IVTV_DBGFLG_HIGHVOL; printf("IVTV_DBGFLG_HIGHVOL%s", MASK_OR_NOTHING); } if (mask) printf("0x%08x", mask); printf("\n"); } static int dowrite(const char *buf, const char *fn) { FILE *f = fopen(fn, "w"); if (f == NULL) { printf("failed: %s\n", strerror(errno)); return errno; } fprintf(f, buf); fclose(f); return 0; } static char *doread(const char *fn) { static char buf[1000]; FILE *f = fopen(fn, "r"); int s; if (f == NULL) { printf("failed: %s\n", strerror(errno)); return NULL; } s = fread(buf, 1, sizeof(buf) - 1, f); buf[s] = 0; fclose(f); return buf; } static const char *field2s(int val) { switch (val) { case V4L2_FIELD_ANY: return "Any"; case V4L2_FIELD_NONE: return "None"; case V4L2_FIELD_TOP: return "Top"; case V4L2_FIELD_BOTTOM: return "Bottom"; case V4L2_FIELD_INTERLACED: return "Interlaced"; case V4L2_FIELD_SEQ_TB: return "Sequential Top-Bottom"; case V4L2_FIELD_SEQ_BT: return "Sequential Bottom-Top"; case V4L2_FIELD_ALTERNATE: return "Alternating"; case V4L2_FIELD_INTERLACED_TB: return "Interlaced Top-Bottom"; case V4L2_FIELD_INTERLACED_BT: return "Interlaced Bottom-Top"; default: return "Unknown"; } } static int doioctl(int fd, int request, void *parm, const char *name) { int retVal; printf("ioctl %s ", name); retVal = ioctl(fd, request, parm); if (retVal < 0) { app_result = -1; printf("failed: %s\n", strerror(errno)); } else printf("ok\n"); return retVal; } int main(int argc, char **argv) { char *value, *subs; int i; char *subopts[] = { #define SUB_VAL 0 "val", #define SUB_YUV_MODE 1 "mode", #define SUB_DIR 2 "dir", #define SUB_INPUT 3 "input", #define SUB_OUTPUT 4 "output", NULL }; int fd = -1; /* bitfield for OptSetCodec */ /* command args */ const char *device = "/dev/video0"; /* -d device */ int ch; int yuv_mode = 0; struct v4l2_routing route; /* audio_route */ unsigned short gpio_out = 0x0; /* GPIO output data */ unsigned short gpio_dir = 0x0; /* GPIO direction bits */ int gpio_set_dir = 0; int passthrough = 0; long audio_mute = 0; long stereo_mode = 0; long bilingual_mode = 0; int debug_level = 0; __u32 reset = 0; int new_debug_level, gdebug_level; double timestamp; char ptsstr[64]; char short_options[26 * 2 * 2 + 1]; if (argc == 1) { usage(); return 0; } while (1) { int option_index = 0; int idx = 0; for (i = 0; long_options[i].name; i++) { if (!isalpha(long_options[i].val)) continue; short_options[idx++] = long_options[i].val; if (long_options[i].has_arg == required_argument) short_options[idx++] = ':'; } short_options[idx] = 0; ch = getopt_long(argc, argv, short_options, long_options, &option_index); if (ch == -1) break; options[(int)ch] = 1; switch (ch) { case OptSetYuvMode: { subs = optarg; while (*subs != '\0') { switch (getsubopt(&subs, subopts, &value)) { case SUB_YUV_MODE: if (value == NULL) { fprintf(stderr, "No value given to suboption \n"); usage(); return 1; } yuv_mode = strtol(value, 0L, 0); if (yuv_mode < 0 || yuv_mode > 3) { fprintf(stderr, "invalid yuv mode\n"); return 1; } break; } } } break; case OptHelp: usage(); return 0; case OptSetDebugLevel:{ debug_level = strtol(optarg, 0L, 0); break; } case OptSetDevice: device = optarg; if (device[0] >= '0' && device[0] <= '9' && device[1] == 0) { static char newdev[20]; char dev = device[0]; sprintf(newdev, "/dev/video%c", dev); device = newdev; } break; case OptSetAudioRoute: subs = optarg; while (*subs != '\0') { switch (getsubopt(&subs, subopts, &value)) { case SUB_INPUT: if (value == NULL) { printf ("No value given to suboption \n"); usage(); } route.input = strtol(value, 0L, 0); break; case SUB_OUTPUT: if (value == NULL) { printf ("No value given to suboption \n"); usage(); } route.output = strtol(value, 0L, 0); break; default: printf ("Invalid suboptions specified\n"); usage(); break; } } break; case OptReset: reset = strtol(optarg, 0L, 0); break; case OptPassThrough: passthrough = strtol(optarg, 0L, 0); break; case OptSetAudioMute: audio_mute = strtol(optarg, 0L, 0); break; case OptSetStereoMode: stereo_mode = strtol(optarg, 0L, 0); break; case OptSetBilingualMode: bilingual_mode = strtol(optarg, 0L, 0); break; case OptSetGPIO: subs = optarg; while (*subs != '\0') { switch (getsubopt(&subs, subopts, &value)) { case SUB_DIR: if (value == NULL) { fprintf(stderr, "No value given to suboption \n"); usage(); exit(1); } gpio_dir = strtol(value, 0L, 0); gpio_set_dir = 1; break; case SUB_VAL: if (value == NULL) { fprintf(stderr, "No value given to suboption \n"); usage(); exit(1); } gpio_out = (unsigned short)strtol(value, 0L, 0); break; default: fprintf(stderr, "Invalid suboptions specified\n"); usage(); exit(1); break; } } break; case ':': fprintf(stderr, "Option `%s' requires a value\n", argv[optind]); usage(); return 1; case '?': fprintf(stderr, "Unknown argument `%s'\n", argv[optind]); usage(); return 1; } } if (optind < argc) { printf("unknown arguments: "); while (optind < argc) printf("%s ", argv[optind++]); printf("\n"); usage(); return 1; } fd = open(device, O_RDWR); if (fd < 0) { fprintf(stderr, "Failed to open %s: %s\n", device, strerror(errno)); exit(1); } /* Setting Opts */ if (options[OptSetAudioRoute]) doioctl(fd, VIDIOC_INT_S_AUDIO_ROUTING, &route, "VIDIOC_INT_S_AUDIO_ROUTING"); if (options[OptFrameSync]) { printf("ioctl: VIDEO_GET_EVENT\n"); for (;;) { struct video_event ev; int fps = 30; v4l2_std_id std; if (ioctl(fd, VIDIOC_G_STD, &std) == 0) fps = (std & V4L2_STD_525_60) ? 30 : 25; if (ioctl(fd, VIDEO_GET_EVENT, &ev) < 0) { fprintf(stderr, "ioctl: VIDEO_GET_EVENT failed\n"); break; } else if (ev.timestamp == 0) { unsigned long long pts = 0, frame = 0; struct timeval tv; gettimeofday(&tv, NULL); timestamp = (double)tv.tv_sec + ((double)tv.tv_usec / 1000000.0); ioctl(fd, VIDEO_GET_PTS, &pts); ioctl(fd, VIDEO_GET_FRAME_COUNT, &frame); pts_to_string(ptsstr, pts, fps); printf("%10.6f: pts %-20s, %lld frames\n", timestamp, ptsstr, frame); } } } if (options[OptSetGPIO]) { struct v4l2_dbg_register reg; reg.match.type = V4L2_CHIP_MATCH_HOST; reg.match.addr = 0; reg.reg = IVTV_REG_GPIO_DIR_OFFSET; reg.val = gpio_dir; if (gpio_set_dir && doioctl(fd, VIDIOC_DBG_S_REGISTER, ®, "VIDIOC_DBG_S_REGISTER") == 0) printf("GPIO dir set to 0x%04llx\n", reg.val); reg.reg = IVTV_REG_GPIO_OUT_OFFSET; reg.val = gpio_out; if (doioctl(fd, VIDIOC_DBG_S_REGISTER, ®, "VIDIOC_DBG_S_REGISTER") == 0) printf("GPIO out set to 0x%04llx\n", reg.val); } if (options[OptListGPIO]) { struct v4l2_dbg_register reg; reg.match.type = V4L2_CHIP_MATCH_HOST; reg.match.addr = 0; reg.reg = IVTV_REG_GPIO_IN_OFFSET; if (ioctl(fd, VIDIOC_DBG_G_REGISTER, ®) == 0) printf("GPIO in: 0x%04llx\n", reg.val); reg.reg = IVTV_REG_GPIO_DIR_OFFSET; if (ioctl(fd, VIDIOC_DBG_G_REGISTER, ®) == 0) printf("GPIO dir: 0x%04llx\n", reg.val); reg.reg = IVTV_REG_GPIO_OUT_OFFSET; if (ioctl(fd, VIDIOC_DBG_G_REGISTER, ®) == 0) printf("GPIO out: 0x%04llx\n", reg.val); } if (options[OptSetDebugLevel]) { char buf[20]; new_debug_level = debug_level; sprintf(buf, "%d", debug_level); if (dowrite(buf, "/sys/module/ivtv/parameters/debug") == 0) { printf(" set debug level: "); print_debug_mask(new_debug_level); printf("\n"); } } if (options[OptGetDebugLevel]) { char *buf = doread("/sys/module/ivtv/parameters/debug"); gdebug_level = 0; if (buf) { gdebug_level = atol(buf); printf(" debug level: "); print_debug_mask(gdebug_level); printf("\n"); } } if (options[OptPassThrough]) { long source = passthrough ? VIDEO_SOURCE_DEMUX : VIDEO_SOURCE_MEMORY; doioctl(fd, VIDEO_SELECT_SOURCE, (void *)source, "IVTV_IOC_PASSTHROUGH"); } if (options[OptSetAudioMute]) { doioctl(fd, AUDIO_SET_MUTE, (void *)audio_mute, "AUDIO_SET_MUTE"); } if (options[OptSetStereoMode]) { doioctl(fd, AUDIO_CHANNEL_SELECT, (void *)stereo_mode, "AUDIO_CHANNEL_SELECT"); } if (options[OptSetBilingualMode]) { doioctl(fd, AUDIO_BILINGUAL_CHANNEL_SELECT, (void *)bilingual_mode, "AUDIO_BILINGUAL_CHANNEL_SELECT"); } if (options[OptReset]) doioctl(fd, VIDIOC_INT_RESET, &reset, "VIDIOC_INT_RESET"); if (options[OptSetYuvMode]) { struct ivtv_dma_frame frame; struct v4l2_format fmt; const enum v4l2_field map[4] = { V4L2_FIELD_INTERLACED_TB, V4L2_FIELD_INTERLACED_BT, V4L2_FIELD_NONE, V4L2_FIELD_ANY, }; printf("set yuv mode\n"); memset(&frame, 0, sizeof(frame)); frame.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; if (ioctl(fd, IVTV_IOC_DMA_FRAME, &frame) < 0) { fprintf(stderr, "Unable to switch to user DMA YUV mode\n"); exit(1); } fmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; ioctl(fd, VIDIOC_G_FMT, &fmt); fmt.fmt.pix.field = map[yuv_mode]; doioctl(fd, VIDIOC_S_FMT, &fmt, "VIDIOC_S_FMT"); } if (options[OptGetYuvMode]) { struct ivtv_dma_frame frame; struct v4l2_format fmt; memset(&frame, 0, sizeof(frame)); frame.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; if (ioctl(fd, IVTV_IOC_DMA_FRAME, &frame) < 0) { fprintf(stderr, "Unable to switch to user DMA YUV mode\n"); exit(1); } fmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; doioctl(fd, VIDIOC_G_FMT, &fmt, "VIDIOC_G_FMT"); printf("Current yuv_mode %d %s\n", fmt.fmt.pix.field, field2s(fmt.fmt.pix.field)); } close(fd); exit(app_result); } ivtv-utils-1.4.1/utils/ivtvplay.cc0000664000076400007640000002535611355717530015674 0ustar andyandy/* * ivtvplay * * This is a simple program to play MPEG files in conjunction with the iTVC15 * driver. It allows seeking to arbitrary GOPs by timestamp and runs a sync * thread to show frames as they are played with cycle-accurate timestamps. * * It is intended as a reference and testing implementation. * * Copyright (c) 2003 Matt T. Yourst * This program is licensed under the GNU General Public License, version 2 */ #define _FILE_OFFSET_BITS 64 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //#undef _FILE_OFFSET_BITS //#include //#define _FILE_OFFSET_BITS 64 #include #include //__NR_sendfile #include #include #include #include #include #include #include #include #include typedef unsigned long W32; typedef unsigned long long W64; static inline W64 rdtsc() { W64 t; asm volatile("rdtsc" : "=A" (t)); return t; } inline int bit(unsigned int v, unsigned int i) { return (v >> i) & 1; } typedef union { struct { uint32_t padding:5, broken:1, closed:1, frame:6, second:6, padding2:1, minute:6, hour:5, drop:1; }; struct { uint32_t data; }; } gop_header_t; struct mpeg_index_entry { unsigned int frame; gop_header_t timestamp; unsigned long long offset; }; struct mpeg_file { struct mpeg_index_entry* index; int index_count; int mpegfd; W64 mpeg_file_size; W64 offset; }; struct ivtv_dec_timing_info { int frame; int ptslo; int ptshi; int scrlo; int scrhi; }; #define IVTV_API_DEC_GET_TIMING 0x00000015 #define IVTV_API_DEC_START_PLAYBACK 0x00000001 #define IVTV_API_DEC_STOP_PLAYBACK 0x00000002 #define IVTV_API_DEC_PAUSE_PLAYBACK 0x0000000d char* timestamp_to_string(char* str, gop_header_t timestamp) { static char buf[256]; char* p = (str) ? str : buf; snprintf(p, sizeof(buf), "%d:%02d:%02d:%d", timestamp.hour, timestamp.minute, timestamp.second, timestamp.frame); return p; } gop_header_t pts_to_timestamp(W32 pts, float fps) { gop_header_t gop; // MPEG "system clock reference" (SCR) and "presentation timestamp" (PTS) run at 90 KHz (90000 ticks per second): #define MPEG_CLOCK_FREQ 90000 int seconds = pts / MPEG_CLOCK_FREQ; int fracsec = pts % MPEG_CLOCK_FREQ; int minutes = seconds / 60; seconds = seconds % 60; int hours = minutes / 60; minutes = minutes % 60; gop.hour = hours; gop.minute = minutes; gop.second = seconds; gop.frame = (int)ceilf(((float)fracsec / (float)MPEG_CLOCK_FREQ) * fps); return gop; } char* pts_to_string(char* str, unsigned long pts) { static char buf[256]; char* p = (str) ? str : buf; int seconds = pts / MPEG_CLOCK_FREQ; int fracsec = pts % MPEG_CLOCK_FREQ; int minutes = seconds / 60; seconds = seconds % 60; int hours = minutes / 60; minutes = minutes % 60; float fps = 30; int frame = (int)ceilf(((float)fracsec / (float)MPEG_CLOCK_FREQ) * fps); snprintf(p, sizeof(buf), "%d:%02d:%02d:%d", hours, minutes, seconds, frame); return p; } static inline gop_header_t make_timestamp(int hour, int minute, int second, int frame) { gop_header_t gop; gop.hour = hour; gop.minute = minute; gop.second = second; gop.frame = frame; return gop; } int mpeg_open(struct mpeg_file* mpeg, char* filename) { int mpegfd; int indexfd; char indexfilename[PATH_MAX]; snprintf(indexfilename, sizeof(indexfilename), "%s.index", filename); if ((mpegfd = open(filename, O_RDONLY | O_LARGEFILE)) < 0) { fprintf(stderr, "Failed to open %s: %s\n", filename, strerror(errno)); return -2; } mpeg->mpegfd = mpegfd; mpeg->mpeg_file_size = lseek64(mpegfd, 0, SEEK_END); lseek64(mpegfd, 0, SEEK_SET); if ((indexfd = open(indexfilename, O_RDONLY | O_LARGEFILE)) < 0) { fprintf(stderr, "Failed to open %s.index: %s\n", filename, strerror(errno)); return -3; } W64 index_size = lseek64(indexfd, 0, SEEK_END); if (index_size < 0) { fprintf(stderr, "Failed to get size of %s.index: %s\n", filename, strerror(errno)); return -4; } mpeg->index = (struct mpeg_index_entry*)mmap(NULL, (W32)index_size, PROT_READ, MAP_PRIVATE, indexfd, 0); if (!mpeg->index) { fprintf(stderr, "Failed to map %s.index: %s\n", filename, strerror(errno)); return -5; } close(indexfd); mpeg->index_count = (W32)index_size / sizeof(struct mpeg_index_entry); printf("Index of %d GOPs:\n", mpeg->index_count); for (int i = 0; i < mpeg->index_count; i++) { //W64 delta = mpeg->index[i+1].offset - mpeg->index[i].offset; //printf(" [% 10d] %-15s (frame % 15d) @ % 20lld (gopsize %d)\n", i, timestamp_to_string(NULL, mpeg->index[i].timestamp), mpeg->index[i].frame, mpeg->index[i].offset, delta); #define MARK_GOP_START 6 //printf("INSERT INTO recordedmarkup (chanid, starttime, mark, type, offset) values ('1011', '20030808233000', %d, %d, \"%lld\");\n", (mpeg->index[i].frame / 15), MARK_GOP_START, mpeg->index[i].offset); ///video/1011_20030808233000_20030809000000.nuv.index } mpeg->offset = 0; return 0; } struct mpeg_index_entry* mpeg_find_nearest(struct mpeg_file* mpeg, const gop_header_t gop) { printf("mpeg_find_nearest: gop = %d\n", gop.data); int lo = 0; int hi = mpeg->index_count-1; int i = (hi + lo) / 2; for (;;) { if (hi == i) return &mpeg->index[i]; i = (lo + hi) / 2; if (gop.data > mpeg->index[i].timestamp.data) lo = i+1; else if (gop.data < mpeg->index[i].timestamp.data) { hi = i-1; } else { return &mpeg->index[i]; } } // (should never be reached) return NULL; } int mpeg_seek_to_time(struct mpeg_file* mpeg, const gop_header_t gop) { struct mpeg_index_entry* idx = mpeg_find_nearest(mpeg, gop); //printf("Searching for timestamp %d:%02d:%02d:%d: found GOP for timestamp %d:%02d:%02d:%d at file offset %lld.\n", //hour, minute, second, frame, idx->timestamp.hour, idx->timestamp.minute, idx->timestamp.second, idx->timestamp.frame, idx->offset); mpeg->offset = idx->offset; return 0; } int writeall(int fd, char* buf, int count) { int origcount = count; while (count > 0) { int n = write(fd, buf, count); if (n < 0) return n; count -= n; buf += n; } return origcount; } int streamfd(int fdout, int fdin, int count) { static const int bufsize = 262144; char buf[bufsize]; int remaining = count; count = 0; while (remaining > 0) { int n = (remaining < bufsize) ? remaining : bufsize; n = read(fdin, buf, n); if (n < 0) return n; int k = writeall(fdout, buf, n); if (k < 0) return k; assert(k == n); remaining -= n; count += n; } return count; } int mpeg_play(struct mpeg_file* mpeg, int videofd, const gop_header_t start_timestamp, const gop_header_t end_timestamp) { static const int bufsize = 65536; char* buf = new char[bufsize]; struct mpeg_index_entry* idx = mpeg_find_nearest(mpeg, start_timestamp); struct mpeg_index_entry* end_idx = mpeg_find_nearest(mpeg, end_timestamp); printf("mpeg_play: playing %lld bytes from %lld to %lld...\n", (end_idx->offset - idx->offset), idx->offset, end_idx->offset); fflush(stdout); printf("Start time: %s (gop %zd)\n", timestamp_to_string(NULL, start_timestamp), (idx - mpeg->index)); printf("End time: %s (gop %zd)\n", timestamp_to_string(NULL, end_timestamp), (end_idx - mpeg->index)); /* int rc; if ((rc = ivtv_api_dec_play(videofd, 0)) < 0) { fprintf(stderr, "ivtvplay: Warning: ivtv_api_dec_play() returned %d\n", rc); } */ while (idx < end_idx) { int chunk_size = ((idx+1)->offset - idx->offset); mpeg->offset = idx->offset; if (streamfd(videofd, mpeg->mpegfd, chunk_size) < 0) { fprintf(stderr, "mpeg_play: error %d (%s)\n", errno, strerror(errno)); goto done; } unsigned long long pts = 0, frame = 0; ioctl(videofd, VIDEO_GET_PTS, &pts); ioctl(videofd, VIDEO_GET_FRAME_COUNT, &frame); if (pts == 0 || frame == 0) { fprintf(stderr, "ioctl: VIDEO_GET_PTS/VIDEO_GET_FRAME_COUNT failed\n"); } else { static const double hz = 1596.027*1000*1000; double tframe = ((double)rdtsc()) / hz; char ptsstr[64]; pts_to_string(ptsstr, pts); printf("%10.6f: gop %-5zd bytes %-7d offset %-12lld pts %-12s frames %lld\n", tframe, (idx - mpeg->index), chunk_size, mpeg->offset, ptsstr, frame); } mpeg->offset += chunk_size; if (mpeg->offset == idx->offset) // end of file? break; idx++; } done: delete[] buf; /* if ((rc = ivtv_api_dec_pause(videofd, 0)) < 0) { fprintf(stderr, "ivtvplay: Warning: ivtv_api_dec_pause() returned %d\n", rc); } */ return 0; } //static int accum = 0; void sync_loop(long videofd) { printf("sync_loop started on videofd %ld\n", videofd); fflush(stdout); //++MTY This applies only to peptidyl: static const double hz = 1596.027*1000*1000; W64 tprev = rdtsc(); for (;;) { struct video_event ev; if (ioctl(videofd, VIDEO_GET_EVENT, &ev) < 0) { fprintf(stderr, "ioctl: VIDEO_GET_EVENT failed\n"); break; } else { W64 tframe = rdtsc(); double tdelta = (tframe - tprev) / hz; unsigned long long pts = 0, frame = 0; tprev = tframe; ioctl(videofd, VIDEO_GET_PTS, &pts); ioctl(videofd, VIDEO_GET_FRAME_COUNT, &frame); char ptsstr[64]; pts_to_string(ptsstr, pts); printf("%10.6f: pts %-20s, %lld frames\n", tdelta, ptsstr, frame); } } } void* sync_thread(void* arg) { sync_loop((long)arg); return NULL; } int main(int argc, char* argv[]) { if (argc < 5) { fprintf(stderr, "Syntax is:\n"); fprintf(stderr, "ivtvplay mpegfile /dev/videoX starthour:minute:second:frame endhour:minute:second:frame\n"); return -1; } struct mpeg_file mpeg; if (mpeg_open(&mpeg, argv[1]) < 0) return -2; int videofd; if ((videofd = open(argv[2], O_WRONLY | O_CREAT | O_APPEND | O_LARGEFILE, 0644)) < 0) { fprintf(stderr, "Failed to open video device %s: %s\n", argv[2], strerror(errno)); return -3; } int hour, minute, second, frame; if (sscanf(argv[3], "%d:%d:%d:%d", &hour, &minute, &second, &frame) != 4) { fprintf(stderr, "Bad start timestamp '%s'\n", argv[3]); return -4; } gop_header_t start_timestamp; start_timestamp.data = 0; start_timestamp.hour = hour; start_timestamp.minute = minute; start_timestamp.second = second; start_timestamp.frame = frame; if (sscanf(argv[4], "%d:%d:%d:%d", &hour, &minute, &second, &frame) != 4) { fprintf(stderr, "Bad end timestamp '%s'\n", argv[4]); return -4; } gop_header_t end_timestamp; end_timestamp.data = 0; end_timestamp.hour = hour; end_timestamp.minute = minute; end_timestamp.second = second; end_timestamp.frame = frame; pthread_t sync_thread_tid; pthread_create(&sync_thread_tid, NULL, sync_thread, (void*)(long)videofd); mpeg_play(&mpeg, videofd, start_timestamp, end_timestamp); return 0; } ivtv-utils-1.4.1/utils/v4l2-ctl.cpp0000664000076400007640000022716411355717530015563 0ustar andyandy/* Copyright (C) 2003-2004 Kevin Thayer Cleanup and VBI and audio in/out options, introduction in v4l-dvb, support for most new APIs since 2006. Copyright (C) 2004, 2006, 2007 Hans Verkuil This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include /* Uses _GNU_SOURCE to define getsubopt in stdlib.h */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* Short option list Please keep in alphabetical order. That makes it easier to see which short options are still free. In general the lower case is used to set something and the upper case is used to retrieve a setting. */ enum Option { OptGetSlicedVbiFormat = 'B', OptSetSlicedVbiFormat = 'b', OptGetCtrl = 'C', OptSetCtrl = 'c', OptSetDevice = 'd', OptGetDriverInfo = 'D', OptGetFreq = 'F', OptSetFreq = 'f', OptHelp = 'h', OptGetInput = 'I', OptSetInput = 'i', OptListCtrls = 'l', OptListCtrlsMenus = 'L', OptListOutputs = 'N', OptListInputs = 'n', OptGetOutput = 'O', OptSetOutput = 'o', OptGetStandard = 'S', OptSetStandard = 's', OptGetTuner = 'T', OptSetTuner = 't', OptGetVideoFormat = 'V', OptSetVideoFormat = 'v', OptGetSlicedVbiOutFormat = 128, OptGetOverlayFormat, OptGetOutputOverlayFormat, OptGetVbiFormat, OptGetVbiOutFormat, OptGetVideoOutFormat, OptSetSlicedVbiOutFormat, OptSetOutputOverlayFormat, OptSetOverlayFormat, //OptSetVbiFormat, TODO //OptSetVbiOutFormat, TODO OptSetVideoOutFormat, OptTryVideoOutFormat, OptTrySlicedVbiOutFormat, OptTrySlicedVbiFormat, OptTryVideoFormat, OptTryOutputOverlayFormat, OptTryOverlayFormat, //OptTryVbiFormat, TODO //OptTryVbiOutFormat, TODO OptAll, OptStreamOff, OptStreamOn, OptListStandards, OptListFormats, OptLogStatus, OptVerbose, OptSilent, OptGetSlicedVbiCap, OptGetSlicedVbiOutCap, OptGetFBuf, OptSetFBuf, OptGetCrop, OptSetCrop, OptGetOutputCrop, OptSetOutputCrop, OptGetOverlayCrop, OptSetOverlayCrop, OptGetOutputOverlayCrop, OptSetOutputOverlayCrop, OptGetAudioInput, OptSetAudioInput, OptGetAudioOutput, OptSetAudioOutput, OptListAudioOutputs, OptListAudioInputs, OptGetCropCap, OptGetOutputCropCap, OptGetOverlayCropCap, OptGetOutputOverlayCropCap, OptOverlay, OptGetJpegComp, OptSetJpegComp, OptListDevices, OptLast = 256 }; static char options[OptLast]; static int app_result; static int verbose; static unsigned capabilities; typedef std::vector ctrl_list; static ctrl_list user_ctrls; static ctrl_list mpeg_ctrls; typedef std::map ctrl_strmap; static ctrl_strmap ctrl_str2id; typedef std::map ctrl_idmap; static ctrl_idmap ctrl_id2str; typedef std::list ctrl_get_list; static ctrl_get_list get_ctrls; typedef std::map ctrl_set_map; static ctrl_set_map set_ctrls; typedef std::vector dev_vec; typedef std::map dev_map; typedef struct { unsigned flag; const char *str; } flag_def; static const flag_def service_def[] = { { V4L2_SLICED_TELETEXT_B, "teletext" }, { V4L2_SLICED_VPS, "vps" }, { V4L2_SLICED_CAPTION_525, "cc" }, { V4L2_SLICED_WSS_625, "wss" }, { 0, NULL } }; /* fmts specified */ #define FmtWidth (1L<<0) #define FmtHeight (1L<<1) #define FmtChromaKey (1L<<2) #define FmtGlobalAlpha (1L<<3) #define FmtPixelFormat (1L<<4) #define FmtLeft (1L<<5) #define FmtTop (1L<<6) #define FmtField (1L<<7) /* crop specified */ #define CropWidth (1L<<0) #define CropHeight (1L<<1) #define CropLeft (1L<<2) #define CropTop (1L<<3) static struct option long_options[] = { {"list-audio-inputs", no_argument, 0, OptListAudioInputs}, {"list-audio-outputs", no_argument, 0, OptListAudioOutputs}, {"all", no_argument, 0, OptAll}, {"device", required_argument, 0, OptSetDevice}, {"get-fmt-video", no_argument, 0, OptGetVideoFormat}, {"set-fmt-video", required_argument, 0, OptSetVideoFormat}, {"try-fmt-video", required_argument, 0, OptTryVideoFormat}, {"get-fmt-video-out", no_argument, 0, OptGetVideoOutFormat}, {"set-fmt-video-out", required_argument, 0, OptSetVideoOutFormat}, {"try-fmt-video-out", required_argument, 0, OptTryVideoOutFormat}, {"help", no_argument, 0, OptHelp}, {"get-output", no_argument, 0, OptGetOutput}, {"set-output", required_argument, 0, OptSetOutput}, {"list-outputs", no_argument, 0, OptListOutputs}, {"list-inputs", no_argument, 0, OptListInputs}, {"get-input", no_argument, 0, OptGetInput}, {"set-input", required_argument, 0, OptSetInput}, {"get-audio-input", no_argument, 0, OptGetAudioInput}, {"set-audio-input", required_argument, 0, OptSetAudioInput}, {"get-audio-output", no_argument, 0, OptGetAudioOutput}, {"set-audio-output", required_argument, 0, OptSetAudioOutput}, {"get-freq", no_argument, 0, OptGetFreq}, {"set-freq", required_argument, 0, OptSetFreq}, {"streamoff", no_argument, 0, OptStreamOff}, {"streamon", no_argument, 0, OptStreamOn}, {"list-standards", no_argument, 0, OptListStandards}, {"list-formats", no_argument, 0, OptListFormats}, {"get-standard", no_argument, 0, OptGetStandard}, {"set-standard", required_argument, 0, OptSetStandard}, {"info", no_argument, 0, OptGetDriverInfo}, {"list-ctrls", no_argument, 0, OptListCtrls}, {"list-ctrls-menus", no_argument, 0, OptListCtrlsMenus}, {"set-ctrl", required_argument, 0, OptSetCtrl}, {"get-ctrl", required_argument, 0, OptGetCtrl}, {"get-tuner", no_argument, 0, OptGetTuner}, {"set-tuner", required_argument, 0, OptSetTuner}, {"verbose", no_argument, 0, OptVerbose}, {"log-status", no_argument, 0, OptLogStatus}, {"get-fmt-overlay", no_argument, 0, OptGetOverlayFormat}, {"set-fmt-overlay", required_argument, 0, OptSetOverlayFormat}, {"try-fmt-overlay", required_argument, 0, OptTryOverlayFormat}, {"get-fmt-output-overlay", no_argument, 0, OptGetOutputOverlayFormat}, {"set-fmt-output-overlay", required_argument, 0, OptSetOutputOverlayFormat}, {"try-fmt-output-overlay", required_argument, 0, OptTryOutputOverlayFormat}, {"get-fmt-sliced-vbi", no_argument, 0, OptGetSlicedVbiFormat}, {"set-fmt-sliced-vbi", required_argument, 0, OptSetSlicedVbiFormat}, {"try-fmt-sliced-vbi", required_argument, 0, OptTrySlicedVbiFormat}, {"get-fmt-sliced-vbi-out", no_argument, 0, OptGetSlicedVbiOutFormat}, {"set-fmt-sliced-vbi-out", required_argument, 0, OptSetSlicedVbiOutFormat}, {"try-fmt-sliced-vbi-out", required_argument, 0, OptTrySlicedVbiOutFormat}, {"get-fmt-vbi", no_argument, 0, OptGetVbiFormat}, {"get-fmt-vbi-out", no_argument, 0, OptGetVbiOutFormat}, {"get-sliced-vbi-cap", no_argument, 0, OptGetSlicedVbiCap}, {"get-sliced-vbi-out-cap", no_argument, 0, OptGetSlicedVbiOutCap}, {"get-fbuf", no_argument, 0, OptGetFBuf}, {"set-fbuf", required_argument, 0, OptSetFBuf}, {"get-cropcap", no_argument, 0, OptGetCropCap}, {"get-crop", no_argument, 0, OptGetCrop}, {"set-crop", required_argument, 0, OptSetCrop}, {"get-cropcap-output", no_argument, 0, OptGetOutputCropCap}, {"get-crop-output", no_argument, 0, OptGetOutputCrop}, {"set-crop-output", required_argument, 0, OptSetOutputCrop}, {"get-cropcap-overlay", no_argument, 0, OptGetOverlayCropCap}, {"get-crop-overlay", no_argument, 0, OptGetOverlayCrop}, {"set-crop-overlay", required_argument, 0, OptSetOverlayCrop}, {"get-cropcap-output-overlay", no_argument, 0, OptGetOutputOverlayCropCap}, {"get-crop-output-overlay", no_argument, 0, OptGetOutputOverlayCrop}, {"set-crop-output-overlay", required_argument, 0, OptSetOutputOverlayCrop}, {"get-jpeg-comp", no_argument, 0, OptGetJpegComp}, {"set-jpeg-comp", required_argument, 0, OptSetJpegComp}, {"overlay", required_argument, 0, OptOverlay}, {"list-devices", no_argument, 0, OptListDevices}, {0, 0, 0, 0} }; static void usage(void) { printf("Usage:\n"); printf("Common options:\n" " --all display all information available\n" " -C, --get-ctrl=[,...]\n" " get the value of the controls [VIDIOC_G_EXT_CTRLS]\n" " -c, --set-ctrl==[,=...]\n" " set the controls to the values specified [VIDIOC_S_EXT_CTRLS]\n" " -D, --info show driver info [VIDIOC_QUERYCAP]\n" " -d, --device= use device instead of /dev/video0\n" " if is a single digit, then /dev/video is used\n" " -F, --get-freq query the frequency [VIDIOC_G_FREQUENCY]\n" " -f, --set-freq=\n" " set the frequency to MHz [VIDIOC_S_FREQUENCY]\n" " -h, --help display this help message\n" " -I, --get-input query the video input [VIDIOC_G_INPUT]\n" " -i, --set-input=\n" " set the video input to [VIDIOC_S_INPUT]\n" " -l, --list-ctrls display all controls and their values [VIDIOC_QUERYCTRL]\n" " -L, --list-ctrls-menus\n" " display all controls, their values and the menus [VIDIOC_QUERYMENU]\n" " -N, --list-outputs display video outputs [VIDIOC_ENUMOUTPUT]\n" " -n, --list-inputs display video inputs [VIDIOC_ENUMINPUT]\n" " -O, --get-output query the video output [VIDIOC_G_OUTPUT]\n" " -o, --set-output=\n" " set the video output to [VIDIOC_S_OUTPUT]\n" " -S, --get-standard\n" " query the video standard [VIDIOC_G_STD]\n" " -s, --set-standard=\n" " set the video standard to [VIDIOC_S_STD]\n" " can be a numerical v4l2_std value, or it can be one of:\n" " pal-X (X = B/G/H/N/Nc/I/D/K/M/60) or just 'pal' (V4L2_STD_PAL)\n" " ntsc-X (X = M/J/K) or just 'ntsc' (V4L2_STD_NTSC)\n" " secam-X (X = B/G/H/D/K/L/Lc) or just 'secam' (V4L2_STD_SECAM)\n" " --list-standards display supported video standards [VIDIOC_ENUMSTD]\n" " -T, --get-tuner query the tuner settings [VIDIOC_G_TUNER]\n" " -t, --set-tuner=\n" " set the audio mode of the tuner [VIDIOC_S_TUNER]\n" " Possible values: mono, stereo, lang2, lang1, bilingual\n" " --list-formats display supported video formats [VIDIOC_ENUM_FMT]\n" " -V, --get-fmt-video\n" " query the video capture format [VIDIOC_G_FMT]\n" " -v, --set-fmt-video=width=,height=,pixelformat=\n" " set the video capture format [VIDIOC_S_FMT]\n" " pixelformat is either the format index as reported by\n" " --list-formats, or the fourcc value as a string\n" " --list-devices list all v4l devices\n" " --silent only set the result code, do not print any messages\n" " --verbose turn on verbose ioctl status reporting\n" "\n"); printf("Uncommon options:\n" " --try-fmt-video=width=,height=,pixelformat=\n" " try the video capture format [VIDIOC_TRY_FMT]\n" " pixelformat is either the format index as reported by\n" " --list-formats, or the fourcc value as a string\n" " --get-fmt-video-out\n" " query the video output format [VIDIOC_G_FMT]\n" " --set-fmt-video-out=width=,height=\n" " set the video output format [VIDIOC_S_FMT]\n" " --try-fmt-video-out=width=,height=\n" " try the video output format [VIDIOC_TRY_FMT]\n" " --get-fmt-overlay query the video overlay format [VIDIOC_G_FMT]\n" " --get-fmt-output-overlay\n" " query the video output overlay format [VIDIOC_G_FMT]\n" " --set-fmt-overlay\n" " --try-fmt-overlay\n" " --set-fmt-output-overlay\n" " --try-fmt-output-overlay=chromakey=,global_alpha=,\n" " top=,left=,width=,height=,field=\n" " set/try the video or video output overlay format [VIDIOC_TRY_FMT]\n" " can be one of:\n" " any, none, top, bottom, interlaced, seq_tb, seq_bt, alternate,\n" " interlaced_tb, interlaced_bt\n" " --get-sliced-vbi-cap\n" " query the sliced VBI capture capabilities [VIDIOC_G_SLICED_VBI_CAP]\n" " --get-sliced-vbi-out-cap\n" " query the sliced VBI output capabilities [VIDIOC_G_SLICED_VBI_CAP]\n" " -B, --get-fmt-sliced-vbi\n" " query the sliced VBI capture format [VIDIOC_G_FMT]\n" " --get-fmt-sliced-vbi-out\n" " query the sliced VBI output format [VIDIOC_G_FMT]\n" " -b, --set-fmt-sliced-vbi\n" " --try-fmt-sliced-vbi\n" " --set-fmt-sliced-vbi-out\n" " --try-fmt-sliced-vbi-out=\n" " (try to) set the sliced VBI capture/output format to [VIDIOC_S/TRY_FMT]\n" " is a comma separated list of:\n" " off: turn off sliced VBI (cannot be combined with other modes)\n" " teletext: teletext (PAL/SECAM)\n" " cc: closed caption (NTSC)\n" " wss: widescreen signal (PAL/SECAM)\n" " vps: VPS (PAL/SECAM)\n" " --get-fmt-vbi query the VBI capture format [VIDIOC_G_FMT]\n" " --get-fmt-vbi-out query the VBI output format [VIDIOC_G_FMT]\n" " --overlay= turn overlay on (1) or off (0) (VIDIOC_OVERLAY)\n" " --get-fbuf query the overlay framebuffer data [VIDIOC_G_FBUF]\n" " --set-fbuf=chromakey=<0/1>,global_alpha=<0/1>,local_alpha=<0/1>,local_inv_alpha=<0/1>\n" " set the overlay framebuffer [VIDIOC_S_FBUF]\n" " --get-cropcap query the crop capabilities [VIDIOC_CROPCAP]\n" " --get-crop query the video capture crop window [VIDIOC_G_CROP]\n" " --set-crop=top=,left=,width=,height=\n" " set the video capture crop window [VIDIOC_S_CROP]\n" " --get-cropcap-output\n" " query the crop capabilities for video output [VIDIOC_CROPCAP]\n" " --get-crop-output query the video output crop window [VIDIOC_G_CROP]\n" " --set-crop-output=top=,left=,width=,height=\n" " set the video output crop window [VIDIOC_S_CROP]\n" " --get-cropcap-overlay\n" " query the crop capabilities for video overlay [VIDIOC_CROPCAP]\n" " --get-crop-overlay query the video overlay crop window [VIDIOC_G_CROP]\n" " --set-crop-overlay=top=,left=,width=,height=\n" " set the video overlay crop window [VIDIOC_S_CROP]\n" " --get-cropcap-output-overlay\n" " query the crop capabilities for video output overlays [VIDIOC_CROPCAP]\n" " --get-crop-output-overlay\n" " query the video output overlay crop window [VIDIOC_G_CROP]\n" " --set-crop-output-overlay=top=,left=,width=,height=\n" " set the video output overlay crop window [VIDIOC_S_CROP]\n" " --get-jpeg-comp query the JPEG compression [VIDIOC_G_JPEGCOMP]\n" " --set-jpeg-comp=quality=,markers=,comment=,app=\n" " set the JPEG compression [VIDIOC_S_JPEGCOMP]\n" " is the app segment: 0-9 or a-f, is the actual string.\n" " is a colon separated list of:\n" " dht: Define Huffman Tables\n" " dqt: Define Quantization Tables\n" " dri: Define Restart Interval\n" " --set-audio-output=\n" " set the audio output to [VIDIOC_S_AUDOUT]\n" " --get-audio-input query the audio input [VIDIOC_G_AUDIO]\n" " --set-audio-input=\n" " set the audio input to [VIDIOC_S_AUDIO]\n" " --get-audio-output query the audio output [VIDIOC_G_AUDOUT]\n" " --set-audio-output=\n" " set the audio output to [VIDIOC_S_AUDOUT]\n" " --list-audio-outputs\n" " display audio outputs [VIDIOC_ENUMAUDOUT]\n" " --list-audio-inputs\n" " display audio inputs [VIDIOC_ENUMAUDIO]\n" "\n"); printf("Expert options:\n" " --streamoff turn the stream off [VIDIOC_STREAMOFF]\n" " --streamon turn the stream on [VIDIOC_STREAMOFF]\n" " --log-status log the board status in the kernel log [VIDIOC_LOG_STATUS]\n"); exit(0); } static std::string num2s(unsigned num) { char buf[10]; sprintf(buf, "%08x", num); return buf; } static std::string buftype2s(int type) { switch (type) { case V4L2_BUF_TYPE_VIDEO_CAPTURE: return "Video Capture"; case V4L2_BUF_TYPE_VIDEO_OUTPUT: return "Video Output"; case V4L2_BUF_TYPE_VIDEO_OVERLAY: return "Video Overlay"; case V4L2_BUF_TYPE_VBI_CAPTURE: return "VBI Capture"; case V4L2_BUF_TYPE_VBI_OUTPUT: return "VBI Output"; case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: return "Sliced VBI Capture"; case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: return "Sliced VBI Output"; case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: return "Video Output Overlay"; case V4L2_BUF_TYPE_PRIVATE: return "Private"; default: return "Unknown (" + num2s(type) + ")"; } } static std::string fcc2s(unsigned int val) { std::string s; s += val & 0xff; s += (val >> 8) & 0xff; s += (val >> 16) & 0xff; s += (val >> 24) & 0xff; return s; } static std::string field2s(int val) { switch (val) { case V4L2_FIELD_ANY: return "Any"; case V4L2_FIELD_NONE: return "None"; case V4L2_FIELD_TOP: return "Top"; case V4L2_FIELD_BOTTOM: return "Bottom"; case V4L2_FIELD_INTERLACED: return "Interlaced"; case V4L2_FIELD_SEQ_TB: return "Sequential Top-Bottom"; case V4L2_FIELD_SEQ_BT: return "Sequential Bottom-Top"; case V4L2_FIELD_ALTERNATE: return "Alternating"; case V4L2_FIELD_INTERLACED_TB: return "Interlaced Top-Bottom"; case V4L2_FIELD_INTERLACED_BT: return "Interlaced Bottom-Top"; default: return "Unknown (" + num2s(val) + ")"; } } static std::string colorspace2s(int val) { switch (val) { case V4L2_COLORSPACE_SMPTE170M: return "Broadcast NTSC/PAL (SMPTE170M/ITU601)"; case V4L2_COLORSPACE_SMPTE240M: return "1125-Line (US) HDTV (SMPTE240M)"; case V4L2_COLORSPACE_REC709: return "HDTV and modern devices (ITU709)"; case V4L2_COLORSPACE_BT878: return "Broken Bt878"; case V4L2_COLORSPACE_470_SYSTEM_M: return "NTSC/M (ITU470/ITU601)"; case V4L2_COLORSPACE_470_SYSTEM_BG: return "PAL/SECAM BG (ITU470/ITU601)"; case V4L2_COLORSPACE_JPEG: return "JPEG (JFIF/ITU601)"; case V4L2_COLORSPACE_SRGB: return "SRGB"; default: return "Unknown (" + num2s(val) + ")"; } } static std::string flags2s(unsigned val, const flag_def *def) { std::string s; while (def->flag) { if (val & def->flag) { if (s.length()) s += " "; s += def->str; } def++; } return s; } static void print_sliced_vbi_cap(struct v4l2_sliced_vbi_cap &cap) { printf("\tType : %s\n", buftype2s(cap.type).c_str()); printf("\tService Set : %s\n", flags2s(cap.service_set, service_def).c_str()); for (int i = 0; i < 24; i++) { printf("\tService Line %2d: %8s / %-8s\n", i, flags2s(cap.service_lines[0][i], service_def).c_str(), flags2s(cap.service_lines[1][i], service_def).c_str()); } } static std::string name2var(unsigned char *name) { std::string s; int add_underscore = 0; while (*name) { if (isalnum(*name)) { if (add_underscore) s += '_'; add_underscore = 0; s += std::string(1, tolower(*name)); } else if (s.length()) add_underscore = 1; name++; } return s; } static void print_qctrl(int fd, struct v4l2_queryctrl *queryctrl, struct v4l2_ext_control *ctrl, int show_menus) { struct v4l2_querymenu qmenu = { 0 }; std::string s = name2var(queryctrl->name); int i; qmenu.id = queryctrl->id; switch (queryctrl->type) { case V4L2_CTRL_TYPE_INTEGER: printf("%31s (int) : min=%d max=%d step=%d default=%d value=%d", s.c_str(), queryctrl->minimum, queryctrl->maximum, queryctrl->step, queryctrl->default_value, ctrl->value); break; case V4L2_CTRL_TYPE_INTEGER64: printf("%31s (int64): value=%lld", s.c_str(), ctrl->value64); break; case V4L2_CTRL_TYPE_BOOLEAN: printf("%31s (bool) : default=%d value=%d", s.c_str(), queryctrl->default_value, ctrl->value); break; case V4L2_CTRL_TYPE_MENU: printf("%31s (menu) : min=%d max=%d default=%d value=%d", s.c_str(), queryctrl->minimum, queryctrl->maximum, queryctrl->default_value, ctrl->value); break; case V4L2_CTRL_TYPE_BUTTON: printf("%31s (button)\n", s.c_str()); break; default: break; } if (queryctrl->flags) { const flag_def def[] = { { V4L2_CTRL_FLAG_GRABBED, "grabbed" }, { V4L2_CTRL_FLAG_READ_ONLY, "read-only" }, { V4L2_CTRL_FLAG_UPDATE, "update" }, { V4L2_CTRL_FLAG_INACTIVE, "inactive" }, { V4L2_CTRL_FLAG_SLIDER, "slider" }, { V4L2_CTRL_FLAG_WRITE_ONLY, "write-only" }, { 0, NULL } }; printf(" flags=%s", flags2s(queryctrl->flags, def).c_str()); } printf("\n"); if (queryctrl->type == V4L2_CTRL_TYPE_MENU && show_menus) { for (i = 0; i <= queryctrl->maximum; i++) { qmenu.index = i; if (ioctl(fd, VIDIOC_QUERYMENU, &qmenu)) continue; printf("\t\t\t\t%d: %s\n", i, qmenu.name); } } } static int print_control(int fd, struct v4l2_queryctrl &qctrl, int show_menus) { struct v4l2_control ctrl = { 0 }; struct v4l2_ext_control ext_ctrl = { 0 }; struct v4l2_ext_controls ctrls = { 0 }; if (qctrl.flags & V4L2_CTRL_FLAG_DISABLED) return 1; if (qctrl.type == V4L2_CTRL_TYPE_CTRL_CLASS) { printf("\n%s\n\n", qctrl.name); return 1; } ext_ctrl.id = qctrl.id; ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(qctrl.id); ctrls.count = 1; ctrls.controls = &ext_ctrl; if (V4L2_CTRL_ID2CLASS(qctrl.id) != V4L2_CTRL_CLASS_USER && qctrl.id < V4L2_CID_PRIVATE_BASE) { if (ioctl(fd, VIDIOC_G_EXT_CTRLS, &ctrls)) { printf("error %d getting ext_ctrl %s\n", errno, qctrl.name); return 0; } } else { ctrl.id = qctrl.id; if (ioctl(fd, VIDIOC_G_CTRL, &ctrl)) { printf("error %d getting ctrl %s\n", errno, qctrl.name); return 0; } ext_ctrl.value = ctrl.value; } print_qctrl(fd, &qctrl, &ext_ctrl, show_menus); return 1; } static void list_controls(int fd, int show_menus) { struct v4l2_queryctrl qctrl = { V4L2_CTRL_FLAG_NEXT_CTRL }; int id; while (ioctl(fd, VIDIOC_QUERYCTRL, &qctrl) == 0) { print_control(fd, qctrl, show_menus); qctrl.id |= V4L2_CTRL_FLAG_NEXT_CTRL; } if (qctrl.id != V4L2_CTRL_FLAG_NEXT_CTRL) return; for (id = V4L2_CID_USER_BASE; id < V4L2_CID_LASTP1; id++) { qctrl.id = id; if (ioctl(fd, VIDIOC_QUERYCTRL, &qctrl) == 0) print_control(fd, qctrl, show_menus); } for (qctrl.id = V4L2_CID_PRIVATE_BASE; ioctl(fd, VIDIOC_QUERYCTRL, &qctrl) == 0; qctrl.id++) { print_control(fd, qctrl, show_menus); } } static void find_controls(int fd) { struct v4l2_queryctrl qctrl = { V4L2_CTRL_FLAG_NEXT_CTRL }; int id; while (ioctl(fd, VIDIOC_QUERYCTRL, &qctrl) == 0) { if (qctrl.type != V4L2_CTRL_TYPE_CTRL_CLASS && !(qctrl.flags & V4L2_CTRL_FLAG_DISABLED)) { ctrl_str2id[name2var(qctrl.name)] = qctrl.id; ctrl_id2str[qctrl.id] = name2var(qctrl.name); } qctrl.id |= V4L2_CTRL_FLAG_NEXT_CTRL; } if (qctrl.id != V4L2_CTRL_FLAG_NEXT_CTRL) return; for (id = V4L2_CID_USER_BASE; id < V4L2_CID_LASTP1; id++) { qctrl.id = id; if (ioctl(fd, VIDIOC_QUERYCTRL, &qctrl) == 0 && !(qctrl.flags & V4L2_CTRL_FLAG_DISABLED)) { ctrl_str2id[name2var(qctrl.name)] = qctrl.id; ctrl_id2str[qctrl.id] = name2var(qctrl.name); } } for (qctrl.id = V4L2_CID_PRIVATE_BASE; ioctl(fd, VIDIOC_QUERYCTRL, &qctrl) == 0; qctrl.id++) { if (!(qctrl.flags & V4L2_CTRL_FLAG_DISABLED)) { ctrl_str2id[name2var(qctrl.name)] = qctrl.id; ctrl_id2str[qctrl.id] = name2var(qctrl.name); } } } static std::string fbufcap2s(unsigned cap) { std::string s; if (cap & V4L2_FBUF_CAP_EXTERNOVERLAY) s += "\t\t\tExtern Overlay\n"; if (cap & V4L2_FBUF_CAP_CHROMAKEY) s += "\t\t\tChromakey\n"; if (cap & V4L2_FBUF_CAP_GLOBAL_ALPHA) s += "\t\t\tGlobal Alpha\n"; if (cap & V4L2_FBUF_CAP_LOCAL_ALPHA) s += "\t\t\tLocal Alpha\n"; if (cap & V4L2_FBUF_CAP_LOCAL_INV_ALPHA) s += "\t\t\tLocal Inverted Alpha\n"; if (cap & V4L2_FBUF_CAP_LIST_CLIPPING) s += "\t\t\tClipping List\n"; if (cap & V4L2_FBUF_CAP_BITMAP_CLIPPING) s += "\t\t\tClipping Bitmap\n"; if (s.empty()) s += "\t\t\t\n"; return s; } static std::string fbufflags2s(unsigned fl) { std::string s; if (fl & V4L2_FBUF_FLAG_PRIMARY) s += "\t\t\tPrimary Graphics Surface\n"; if (fl & V4L2_FBUF_FLAG_OVERLAY) s += "\t\t\tOverlay Matches Capture/Output Size\n"; if (fl & V4L2_FBUF_FLAG_CHROMAKEY) s += "\t\t\tChromakey\n"; if (fl & V4L2_FBUF_FLAG_GLOBAL_ALPHA) s += "\t\t\tGlobal Alpha\n"; if (fl & V4L2_FBUF_FLAG_LOCAL_ALPHA) s += "\t\t\tLocal Alpha\n"; if (fl & V4L2_FBUF_FLAG_LOCAL_INV_ALPHA) s += "\t\t\tLocal Inverted Alpha\n"; if (s.empty()) s += "\t\t\t\n"; return s; } static void printfbuf(const struct v4l2_framebuffer &fb) { int is_ext = fb.capability & V4L2_FBUF_CAP_EXTERNOVERLAY; printf("Framebuffer Format:\n"); printf("\tCapability : %s", fbufcap2s(fb.capability).c_str() + 3); printf("\tFlags : %s", fbufflags2s(fb.flags).c_str() + 3); if (fb.base) printf("\tBase : 0x%p\n", fb.base); printf("\tWidth : %d\n", fb.fmt.width); printf("\tHeight : %d\n", fb.fmt.height); printf("\tPixel Format : '%s'\n", fcc2s(fb.fmt.pixelformat).c_str()); if (!is_ext) { printf("\tBytes per Line: %d\n", fb.fmt.bytesperline); printf("\tSize image : %d\n", fb.fmt.sizeimage); printf("\tColorspace : %s\n", colorspace2s(fb.fmt.colorspace).c_str()); if (fb.fmt.priv) printf("\tCustom Info : %08x\n", fb.fmt.priv); } } static std::string markers2s(unsigned markers) { std::string s; if (markers & V4L2_JPEG_MARKER_DHT) s += "\t\tDefine Huffman Tables\n"; if (markers & V4L2_JPEG_MARKER_DQT) s += "\t\tDefine Quantization Tables\n"; if (markers & V4L2_JPEG_MARKER_DRI) s += "\t\tDefine Restart Interval\n"; if (markers & V4L2_JPEG_MARKER_COM) s += "\t\tDefine Comment\n"; if (markers & V4L2_JPEG_MARKER_APP) s += "\t\tDefine APP segment\n"; return s; } static void printjpegcomp(const struct v4l2_jpegcompression &jc) { printf("JPEG compression:\n"); printf("\tQuality: %d\n", jc.quality); if (jc.COM_len) printf("\tComment: '%s'\n", jc.COM_data); if (jc.APP_len) printf("\tAPP%x : '%s'\n", jc.APPn, jc.APP_data); printf("\tMarkers: 0x%08lx\n", jc.jpeg_markers); printf("%s", markers2s(jc.jpeg_markers).c_str()); } static void printcrop(const struct v4l2_crop &crop) { printf("Crop: Left %d, Top %d, Width %d, Height %d\n", crop.c.left, crop.c.top, crop.c.width, crop.c.height); } static void printcropcap(const struct v4l2_cropcap &cropcap) { printf("Crop Capability %s:\n", buftype2s(cropcap.type).c_str()); printf("\tBounds : Left %d, Top %d, Width %d, Height %d\n", cropcap.bounds.left, cropcap.bounds.top, cropcap.bounds.width, cropcap.bounds.height); printf("\tDefault : Left %d, Top %d, Width %d, Height %d\n", cropcap.defrect.left, cropcap.defrect.top, cropcap.defrect.width, cropcap.defrect.height); printf("\tPixel Aspect: %u/%u\n", cropcap.pixelaspect.numerator, cropcap.pixelaspect.denominator); } static void printfmt(struct v4l2_format vfmt) { const flag_def vbi_def[] = { { V4L2_VBI_UNSYNC, "unsynchronized" }, { V4L2_VBI_INTERLACED, "interlaced" }, { 0, NULL } }; printf("Format %s:\n", buftype2s(vfmt.type).c_str()); switch (vfmt.type) { case V4L2_BUF_TYPE_VIDEO_CAPTURE: case V4L2_BUF_TYPE_VIDEO_OUTPUT: printf("\tWidth/Height : %u/%u\n", vfmt.fmt.pix.width, vfmt.fmt.pix.height); printf("\tPixel Format : '%s'\n", fcc2s(vfmt.fmt.pix.pixelformat).c_str()); printf("\tField : %s\n", field2s(vfmt.fmt.pix.field).c_str()); printf("\tBytes per Line: %u\n", vfmt.fmt.pix.bytesperline); printf("\tSize Image : %u\n", vfmt.fmt.pix.sizeimage); printf("\tColorspace : %s\n", colorspace2s(vfmt.fmt.pix.colorspace).c_str()); if (vfmt.fmt.pix.priv) printf("\tCustom Info : %08x\n", vfmt.fmt.pix.priv); break; case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: case V4L2_BUF_TYPE_VIDEO_OVERLAY: printf("\tLeft/Top : %d/%d\n", vfmt.fmt.win.w.left, vfmt.fmt.win.w.top); printf("\tWidth/Height: %d/%d\n", vfmt.fmt.win.w.width, vfmt.fmt.win.w.height); printf("\tField : %s\n", field2s(vfmt.fmt.win.field).c_str()); printf("\tChroma Key : 0x%08x\n", vfmt.fmt.win.chromakey); printf("\tGlobal Alpha: 0x%02x\n", vfmt.fmt.win.global_alpha); printf("\tClip Count : %u\n", vfmt.fmt.win.clipcount); printf("\tClip Bitmap : %s\n", vfmt.fmt.win.bitmap ? "Yes" : "No"); break; case V4L2_BUF_TYPE_VBI_CAPTURE: case V4L2_BUF_TYPE_VBI_OUTPUT: printf("\tSampling Rate : %u Hz\n", vfmt.fmt.vbi.sampling_rate); printf("\tOffset : %u samples (%g secs after leading edge)\n", vfmt.fmt.vbi.offset, (double)vfmt.fmt.vbi.offset / (double)vfmt.fmt.vbi.sampling_rate); printf("\tSamples per Line: %u\n", vfmt.fmt.vbi.samples_per_line); printf("\tSample Format : %s\n", fcc2s(vfmt.fmt.vbi.sample_format).c_str()); printf("\tStart 1st Field : %u\n", vfmt.fmt.vbi.start[0]); printf("\tCount 1st Field : %u\n", vfmt.fmt.vbi.count[0]); printf("\tStart 2nd Field : %u\n", vfmt.fmt.vbi.start[1]); printf("\tCount 2nd Field : %u\n", vfmt.fmt.vbi.count[1]); if (vfmt.fmt.vbi.flags) printf("\tFlags : %s\n", flags2s(vfmt.fmt.vbi.flags, vbi_def).c_str()); break; case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: printf("\tService Set : %s\n", flags2s(vfmt.fmt.sliced.service_set, service_def).c_str()); for (int i = 0; i < 24; i++) { printf("\tService Line %2d: %8s / %-8s\n", i, flags2s(vfmt.fmt.sliced.service_lines[0][i], service_def).c_str(), flags2s(vfmt.fmt.sliced.service_lines[1][i], service_def).c_str()); } printf("\tI/O Size : %u\n", vfmt.fmt.sliced.io_size); break; case V4L2_BUF_TYPE_PRIVATE: break; } } static void print_video_formats(int fd, enum v4l2_buf_type type) { struct v4l2_fmtdesc fmt; fmt.index = 0; fmt.type = type; while (ioctl(fd, VIDIOC_ENUM_FMT, &fmt) >= 0) { printf("\tIndex : %d\n", fmt.index); printf("\tType : %s\n", buftype2s(type).c_str()); printf("\tPixel Format: '%s'", fcc2s(fmt.pixelformat).c_str()); if (fmt.flags) printf(" (compressed)"); printf("\n"); printf("\tName : %s\n", fmt.description); printf("\n"); fmt.index++; } } static char *pts_to_string(char *str, unsigned long pts) { static char buf[256]; int hours, minutes, seconds, fracsec; float fps; int frame; char *p = (str) ? str : buf; static const int MPEG_CLOCK_FREQ = 90000; seconds = pts / MPEG_CLOCK_FREQ; fracsec = pts % MPEG_CLOCK_FREQ; minutes = seconds / 60; seconds = seconds % 60; hours = minutes / 60; minutes = minutes % 60; fps = 30; frame = (int)ceilf(((float)fracsec / (float)MPEG_CLOCK_FREQ) * fps); snprintf(p, sizeof(buf), "%d:%02d:%02d:%d", hours, minutes, seconds, frame); return p; } static const char *audmode2s(int audmode) { switch (audmode) { case V4L2_TUNER_MODE_STEREO: return "stereo"; case V4L2_TUNER_MODE_LANG1: return "lang1"; case V4L2_TUNER_MODE_LANG2: return "lang2"; case V4L2_TUNER_MODE_LANG1_LANG2: return "bilingual"; case V4L2_TUNER_MODE_MONO: return "mono"; default: return "unknown"; } } static std::string rxsubchans2s(int rxsubchans) { std::string s; if (rxsubchans & V4L2_TUNER_SUB_MONO) s += "mono "; if (rxsubchans & V4L2_TUNER_SUB_STEREO) s += "stereo "; if (rxsubchans & V4L2_TUNER_SUB_LANG1) s += "lang1 "; if (rxsubchans & V4L2_TUNER_SUB_LANG2) s += "lang2 "; return s; } static std::string tcap2s(unsigned cap) { std::string s; if (cap & V4L2_TUNER_CAP_LOW) s += "62.5 Hz "; else s += "62.5 kHz "; if (cap & V4L2_TUNER_CAP_NORM) s += "multi-standard "; if (cap & V4L2_TUNER_CAP_STEREO) s += "stereo "; if (cap & V4L2_TUNER_CAP_LANG1) s += "lang1 "; if (cap & V4L2_TUNER_CAP_LANG2) s += "lang2 "; return s; } static std::string cap2s(unsigned cap) { std::string s; if (cap & V4L2_CAP_VIDEO_CAPTURE) s += "\t\tVideo Capture\n"; if (cap & V4L2_CAP_VIDEO_OUTPUT) s += "\t\tVideo Output\n"; if (cap & V4L2_CAP_VIDEO_OVERLAY) s += "\t\tVideo Overlay\n"; if (cap & V4L2_CAP_VIDEO_OUTPUT_OVERLAY) s += "\t\tVideo Output Overlay\n"; if (cap & V4L2_CAP_VBI_CAPTURE) s += "\t\tVBI Capture\n"; if (cap & V4L2_CAP_VBI_OUTPUT) s += "\t\tVBI Output\n"; if (cap & V4L2_CAP_SLICED_VBI_CAPTURE) s += "\t\tSliced VBI Capture\n"; if (cap & V4L2_CAP_SLICED_VBI_OUTPUT) s += "\t\tSliced VBI Output\n"; if (cap & V4L2_CAP_RDS_CAPTURE) s += "\t\tRDS Capture\n"; if (cap & V4L2_CAP_TUNER) s += "\t\tTuner\n"; if (cap & V4L2_CAP_AUDIO) s += "\t\tAudio\n"; if (cap & V4L2_CAP_RADIO) s += "\t\tRadio\n"; if (cap & V4L2_CAP_READWRITE) s += "\t\tRead/Write\n"; if (cap & V4L2_CAP_ASYNCIO) s += "\t\tAsync I/O\n"; if (cap & V4L2_CAP_STREAMING) s += "\t\tStreaming\n"; return s; } static v4l2_std_id parse_pal(const char *pal) { if (pal[0] == '-') { switch (pal[1]) { case '6': return V4L2_STD_PAL_60; case 'b': case 'B': case 'g': case 'G': return V4L2_STD_PAL_BG; case 'h': case 'H': return V4L2_STD_PAL_H; case 'n': case 'N': if (pal[2] == 'c' || pal[2] == 'C') return V4L2_STD_PAL_Nc; return V4L2_STD_PAL_N; case 'i': case 'I': return V4L2_STD_PAL_I; case 'd': case 'D': case 'k': case 'K': return V4L2_STD_PAL_DK; case 'M': case 'm': return V4L2_STD_PAL_M; case '-': break; } } fprintf(stderr, "pal specifier not recognised\n"); return 0; } static v4l2_std_id parse_secam(const char *secam) { if (secam[0] == '-') { switch (secam[1]) { case 'b': case 'B': case 'g': case 'G': case 'h': case 'H': return V4L2_STD_SECAM_B | V4L2_STD_SECAM_G | V4L2_STD_SECAM_H; case 'd': case 'D': case 'k': case 'K': return V4L2_STD_SECAM_DK; case 'l': case 'L': if (secam[2] == 'C' || secam[2] == 'c') return V4L2_STD_SECAM_LC; return V4L2_STD_SECAM_L; case '-': break; } } fprintf(stderr, "secam specifier not recognised\n"); return 0; } static v4l2_std_id parse_ntsc(const char *ntsc) { if (ntsc[0] == '-') { switch (ntsc[1]) { case 'm': case 'M': return V4L2_STD_NTSC_M; case 'j': case 'J': return V4L2_STD_NTSC_M_JP; case 'k': case 'K': return V4L2_STD_NTSC_M_KR; case '-': break; } } fprintf(stderr, "ntsc specifier not recognised\n"); return 0; } static int doioctl(int fd, int request, void *parm, const char *name) { int retVal = ioctl(fd, request, parm); if (retVal < 0) { app_result = -1; } if (options[OptSilent]) return retVal; if (retVal < 0) printf("%s: failed: %s\n", name, strerror(errno)); else if (verbose) printf("%s: ok\n", name); return retVal; } static bool is_v4l_dev(const char *name) { return !memcmp(name, "vtx", 3) || !memcmp(name, "video", 5) || !memcmp(name, "radio", 5) || !memcmp(name, "vbi", 3); } static int calc_node_val(const char *s) { int n = 0; s = strrchr(s, '/') + 1; if (!memcmp(s, "video", 5)) n = 0; else if (!memcmp(s, "radio", 5)) n = 0x100; else if (!memcmp(s, "vbi", 3)) n = 0x200; else if (!memcmp(s, "vtx", 3)) n = 0x300; n += atol(s + (n >= 0x200 ? 3 : 5)); return n; } static bool sort_on_device_name(const std::string &s1, const std::string &s2) { int n1 = calc_node_val(s1.c_str()); int n2 = calc_node_val(s2.c_str()); return n1 < n2; } static void list_devices() { DIR *dp; struct dirent *ep; dev_vec files; dev_map links; dev_map cards; struct v4l2_capability vcap; dp = opendir("/dev"); if (dp == NULL) { perror ("Couldn't open the directory"); return; } while (ep = readdir(dp)) if (is_v4l_dev(ep->d_name)) files.push_back(std::string("/dev/") + ep->d_name); closedir(dp); #if 0 dp = opendir("/dev/v4l"); if (dp) { while (ep = readdir(dp)) if (is_v4l_dev(ep->d_name)) files.push_back(std::string("/dev/v4l/") + ep->d_name); closedir(dp); } #endif /* Find device nodes which are links to other device nodes */ for (dev_vec::iterator iter = files.begin(); iter != files.end(); ) { char link[64+1]; int link_len; std::string target; link_len = readlink(iter->c_str(), link, 64); if (link_len < 0) { /* Not a link or error */ iter++; continue; } link[link_len] = '\0'; /* Only remove from files list if target itself is in list */ if (link[0] != '/') /* Relative link */ target = std::string("/dev/"); target += link; if (find(files.begin(), files.end(), target) == files.end()) { iter++; continue; } /* Move the device node from files to links */ if (links[target].empty()) links[target] = *iter; else links[target] += ", " + *iter; files.erase(iter); } std::sort(files.begin(), files.end(), sort_on_device_name); for (dev_vec::iterator iter = files.begin(); iter != files.end(); ++iter) { int fd = open(iter->c_str(), O_RDWR); std::string bus_info; if (fd < 0) continue; doioctl(fd, VIDIOC_QUERYCAP, &vcap, "VIDIOC_QUERYCAP"); close(fd); bus_info = (const char *)vcap.bus_info; if (cards[bus_info].empty()) cards[bus_info] += std::string((char *)vcap.card) + " (" + bus_info + "):\n"; cards[bus_info] += "\t" + (*iter); if (!(links[*iter].empty())) cards[bus_info] += " <- " + links[*iter]; cards[bus_info] += "\n"; } for (dev_map::iterator iter = cards.begin(); iter != cards.end(); ++iter) { printf("%s\n", iter->second.c_str()); } } static int parse_subopt(char **subs, const char * const *subopts, char **value) { int opt = getsubopt(subs, (char * const *)subopts, value); if (opt == -1) { fprintf(stderr, "Invalid suboptions specified\n"); usage(); exit(1); } if (value == NULL) { fprintf(stderr, "No value given to suboption <%s>\n", subopts[opt]); usage(); exit(1); } return opt; } static void parse_next_subopt(char **subs, char **value) { static char *const subopts[] = { NULL }; int opt = getsubopt(subs, subopts, value); if (value == NULL) { fprintf(stderr, "No value given to suboption <%s>\n", subopts[opt]); usage(); exit(1); } } static void print_std(const char *prefix, const char *stds[], unsigned long long std) { int first = 1; printf("\t%s-", prefix); while (*stds) { if (std & 1) { if (!first) printf("/"); first = 0; printf("%s", *stds); } stds++; std >>= 1; } printf("\n"); } static void do_crop(int fd, unsigned int set_crop, struct v4l2_rect &vcrop, v4l2_buf_type type) { struct v4l2_crop in_crop; in_crop.type = type; if (doioctl(fd, VIDIOC_G_CROP, &in_crop, "VIDIOC_G_CROP") == 0) { if (set_crop & CropWidth) in_crop.c.width = vcrop.width; if (set_crop & CropHeight) in_crop.c.height = vcrop.height; if (set_crop & CropLeft) in_crop.c.left = vcrop.left; if (set_crop & CropTop) in_crop.c.top = vcrop.top; doioctl(fd, VIDIOC_S_CROP, &in_crop, "VIDIOC_S_CROP"); } } static void parse_crop(char *optarg, unsigned int &set_crop, v4l2_rect &vcrop) { char *value; char *subs = optarg; while (*subs != '\0') { static const char *const subopts[] = { "left", "top", "width", "height", NULL }; switch (parse_subopt(&subs, subopts, &value)) { case 0: vcrop.left = strtol(value, 0L, 0); set_crop |= CropLeft; break; case 1: vcrop.top = strtol(value, 0L, 0); set_crop |= CropTop; break; case 2: vcrop.width = strtol(value, 0L, 0); set_crop |= CropWidth; break; case 3: vcrop.height = strtol(value, 0L, 0); set_crop |= CropHeight; break; } } } static enum v4l2_field parse_field(const char *s) { if (!strcmp(s, "any")) return V4L2_FIELD_ANY; if (!strcmp(s, "none")) return V4L2_FIELD_NONE; if (!strcmp(s, "top")) return V4L2_FIELD_TOP; if (!strcmp(s, "bottom")) return V4L2_FIELD_BOTTOM; if (!strcmp(s, "interlaced")) return V4L2_FIELD_INTERLACED; if (!strcmp(s, "seq_tb")) return V4L2_FIELD_SEQ_TB; if (!strcmp(s, "seq_bt")) return V4L2_FIELD_SEQ_BT; if (!strcmp(s, "alternate")) return V4L2_FIELD_ALTERNATE; if (!strcmp(s, "interlaced_tb")) return V4L2_FIELD_INTERLACED_TB; if (!strcmp(s, "interlaced_bt")) return V4L2_FIELD_INTERLACED_BT; return V4L2_FIELD_ANY; } int main(int argc, char **argv) { char *value, *subs; int i; int fd = -1; /* bitfield for fmts */ unsigned int set_fmts = 0; unsigned int set_fmts_out = 0; unsigned int set_crop = 0; unsigned int set_crop_out = 0; unsigned int set_crop_overlay = 0; unsigned int set_crop_out_overlay = 0; unsigned int set_fbuf = 0; unsigned int set_overlay_fmt = 0; unsigned int set_overlay_fmt_out = 0; int mode = V4L2_TUNER_MODE_STEREO; /* set audio mode */ /* command args */ int ch; const char *device = "/dev/video0"; /* -d device */ struct v4l2_format vfmt; /* set_format/get_format for video */ struct v4l2_format vfmt_out; /* set_format/get_format video output */ struct v4l2_format vbi_fmt; /* set_format/get_format for sliced VBI */ struct v4l2_format vbi_fmt_out; /* set_format/get_format for sliced VBI output */ struct v4l2_format raw_fmt; /* set_format/get_format for VBI */ struct v4l2_format raw_fmt_out; /* set_format/get_format for VBI output */ struct v4l2_format overlay_fmt; /* set_format/get_format video overlay */ struct v4l2_format overlay_fmt_out; /* set_format/get_format video overlay output */ struct v4l2_tuner tuner; /* set_tuner/get_tuner */ struct v4l2_capability vcap; /* list_cap */ struct v4l2_input vin; /* list_inputs */ struct v4l2_output vout; /* list_outputs */ struct v4l2_audio vaudio; /* list audio inputs */ struct v4l2_audioout vaudout; /* audio outputs */ struct v4l2_rect vcrop; /* crop rect */ struct v4l2_rect vcrop_out; /* crop rect */ struct v4l2_rect vcrop_overlay; /* crop rect */ struct v4l2_rect vcrop_out_overlay; /* crop rect */ struct v4l2_framebuffer fbuf; /* fbuf */ struct v4l2_jpegcompression jpegcomp; /* jpeg compression */ int input; /* set_input/get_input */ int output; /* set_output/get_output */ v4l2_std_id std; /* get_std/set_std */ double freq = 0; /* get/set frequency */ struct v4l2_frequency vf; /* get_freq/set_freq */ struct v4l2_standard vs; /* list_std */ int overlay; /* overlay */ unsigned int *set_overlay_fmt_ptr; struct v4l2_format *overlay_fmt_ptr; char short_options[26 * 2 * 2 + 1]; int idx = 0; int ret; memset(&vfmt, 0, sizeof(vfmt)); memset(&vbi_fmt, 0, sizeof(vbi_fmt)); memset(&raw_fmt, 0, sizeof(raw_fmt)); memset(&vfmt_out, 0, sizeof(vfmt_out)); memset(&vbi_fmt_out, 0, sizeof(vbi_fmt_out)); memset(&overlay_fmt, 0, sizeof(overlay_fmt)); memset(&overlay_fmt_out, 0, sizeof(overlay_fmt_out)); memset(&raw_fmt_out, 0, sizeof(raw_fmt_out)); memset(&tuner, 0, sizeof(tuner)); memset(&vcap, 0, sizeof(vcap)); memset(&vin, 0, sizeof(vin)); memset(&vout, 0, sizeof(vout)); memset(&vaudio, 0, sizeof(vaudio)); memset(&vaudout, 0, sizeof(vaudout)); memset(&vcrop, 0, sizeof(vcrop)); memset(&vcrop_out, 0, sizeof(vcrop_out)); memset(&vcrop_overlay, 0, sizeof(vcrop_overlay)); memset(&vcrop_out_overlay, 0, sizeof(vcrop_out_overlay)); memset(&vf, 0, sizeof(vf)); memset(&vs, 0, sizeof(vs)); memset(&fbuf, 0, sizeof(fbuf)); memset(&jpegcomp, 0, sizeof(jpegcomp)); if (argc == 1) { usage(); return 0; } for (i = 0; long_options[i].name; i++) { if (!isalpha(long_options[i].val)) continue; short_options[idx++] = long_options[i].val; if (long_options[i].has_arg == required_argument) short_options[idx++] = ':'; } while (1) { int option_index = 0; short_options[idx] = 0; ch = getopt_long(argc, argv, short_options, long_options, &option_index); if (ch == -1) break; options[(int)ch] = 1; switch (ch) { case OptHelp: usage(); return 0; case OptSetDevice: device = optarg; if (device[0] >= '0' && device[0] <= '9' && device[1] == 0) { static char newdev[20]; char dev = device[0]; sprintf(newdev, "/dev/video%c", dev); device = newdev; } break; case OptSetVideoFormat: case OptTryVideoFormat: subs = optarg; while (*subs != '\0') { static const char *const subopts[] = { "width", "height", "pixelformat", NULL }; switch (parse_subopt(&subs, subopts, &value)) { case 0: vfmt.fmt.pix.width = strtol(value, 0L, 0); set_fmts |= FmtWidth; break; case 1: vfmt.fmt.pix.height = strtol(value, 0L, 0); set_fmts |= FmtHeight; break; case 2: if (strlen(value) == 4) vfmt.fmt.pix.pixelformat = v4l2_fourcc(value[0], value[1], value[2], value[3]); else vfmt.fmt.pix.pixelformat = strtol(value, 0L, 0); set_fmts |= FmtPixelFormat; break; } } break; case OptSetVideoOutFormat: case OptTryVideoOutFormat: subs = optarg; while (*subs != '\0') { static const char *const subopts[] = { "width", "height", NULL }; switch (parse_subopt(&subs, subopts, &value)) { case 0: vfmt_out.fmt.pix.width = strtol(value, 0L, 0); set_fmts_out |= FmtWidth; break; case 1: vfmt_out.fmt.pix.height = strtol(value, 0L, 0); set_fmts_out |= FmtHeight; break; } } break; case OptSetOverlayFormat: case OptTryOverlayFormat: case OptSetOutputOverlayFormat: case OptTryOutputOverlayFormat: switch (ch) { case OptSetOverlayFormat: case OptTryOverlayFormat: set_overlay_fmt_ptr = &set_overlay_fmt; overlay_fmt_ptr = &overlay_fmt; break; case OptSetOutputOverlayFormat: case OptTryOutputOverlayFormat: set_overlay_fmt_ptr = &set_overlay_fmt_out; overlay_fmt_ptr = &overlay_fmt_out; break; } subs = optarg; while (*subs != '\0') { static const char *const subopts[] = { "chromakey", "global_alpha", "left", "top", "width", "height", "field", NULL }; switch (parse_subopt(&subs, subopts, &value)) { case 0: overlay_fmt_ptr->fmt.win.chromakey = strtol(value, 0L, 0); *set_overlay_fmt_ptr |= FmtChromaKey; break; case 1: overlay_fmt_ptr->fmt.win.global_alpha = strtol(value, 0L, 0); *set_overlay_fmt_ptr |= FmtGlobalAlpha; break; case 2: overlay_fmt_ptr->fmt.win.w.left = strtol(value, 0L, 0); *set_overlay_fmt_ptr |= FmtLeft; break; case 3: overlay_fmt_ptr->fmt.win.w.top = strtol(value, 0L, 0); *set_overlay_fmt_ptr |= FmtTop; break; case 4: overlay_fmt_ptr->fmt.win.w.width = strtol(value, 0L, 0); *set_overlay_fmt_ptr |= FmtWidth; break; case 5: overlay_fmt_ptr->fmt.win.w.height = strtol(value, 0L, 0); *set_overlay_fmt_ptr |= FmtHeight; break; case 6: overlay_fmt_ptr->fmt.win.field = parse_field(value); *set_overlay_fmt_ptr |= FmtField; break; } } break; case OptSetFBuf: subs = optarg; while (*subs != '\0') { static const char *const subopts[] = { "chromakey", "global_alpha", "local_alpha", "local_inv_alpha", NULL }; switch (parse_subopt(&subs, subopts, &value)) { case 0: fbuf.flags |= strtol(value, 0L, 0) ? V4L2_FBUF_FLAG_CHROMAKEY : 0; set_fbuf |= V4L2_FBUF_FLAG_CHROMAKEY; break; case 1: fbuf.flags |= strtol(value, 0L, 0) ? V4L2_FBUF_FLAG_GLOBAL_ALPHA : 0; set_fbuf |= V4L2_FBUF_FLAG_GLOBAL_ALPHA; break; case 2: fbuf.flags |= strtol(value, 0L, 0) ? V4L2_FBUF_FLAG_LOCAL_ALPHA : 0; set_fbuf |= V4L2_FBUF_FLAG_LOCAL_ALPHA; break; case 3: fbuf.flags |= strtol(value, 0L, 0) ? V4L2_FBUF_FLAG_LOCAL_INV_ALPHA : 0; set_fbuf |= V4L2_FBUF_FLAG_LOCAL_INV_ALPHA; break; } } break; case OptOverlay: overlay = strtol(optarg, 0L, 0); break; case OptSetCrop: parse_crop(optarg, set_crop, vcrop); break; case OptSetOutputCrop: parse_crop(optarg, set_crop_out, vcrop_out); break; case OptSetOverlayCrop: parse_crop(optarg, set_crop_overlay, vcrop_overlay); break; case OptSetOutputOverlayCrop: parse_crop(optarg, set_crop_out_overlay, vcrop_out_overlay); break; case OptSetInput: input = strtol(optarg, 0L, 0); break; case OptSetOutput: output = strtol(optarg, 0L, 0); break; case OptSetAudioInput: vaudio.index = strtol(optarg, 0L, 0); break; case OptSetAudioOutput: vaudout.index = strtol(optarg, 0L, 0); break; case OptSetFreq: freq = strtod(optarg, NULL); break; case OptSetStandard: if (!strncmp(optarg, "pal", 3)) { if (optarg[3]) std = parse_pal(optarg + 3); else std = V4L2_STD_PAL; } else if (!strncmp(optarg, "ntsc", 4)) { if (optarg[4]) std = parse_ntsc(optarg + 4); else std = V4L2_STD_NTSC; } else if (!strncmp(optarg, "secam", 5)) { if (optarg[5]) std = parse_secam(optarg + 5); else std = V4L2_STD_SECAM; } else { std = strtol(optarg, 0L, 0) | (1ULL << 63); } break; case OptGetCtrl: subs = optarg; while (*subs != '\0') { parse_next_subopt(&subs, &value); if (strchr(value, '=')) { usage(); exit(1); } else { get_ctrls.push_back(value); } } break; case OptSetCtrl: subs = optarg; while (*subs != '\0') { parse_next_subopt(&subs, &value); if (const char *equal = strchr(value, '=')) { set_ctrls[std::string(value, (equal - value))] = equal + 1; } else { fprintf(stderr, "control '%s' without '='\n", value); exit(1); } } break; case OptSetTuner: if (!strcmp(optarg, "stereo")) mode = V4L2_TUNER_MODE_STEREO; else if (!strcmp(optarg, "lang1")) mode = V4L2_TUNER_MODE_LANG1; else if (!strcmp(optarg, "lang2")) mode = V4L2_TUNER_MODE_LANG2; else if (!strcmp(optarg, "bilingual")) mode = V4L2_TUNER_MODE_LANG1_LANG2; else if (!strcmp(optarg, "mono")) mode = V4L2_TUNER_MODE_MONO; else { fprintf(stderr, "Unknown audio mode\n"); usage(); return 1; } break; case OptSetSlicedVbiFormat: case OptSetSlicedVbiOutFormat: case OptTrySlicedVbiFormat: case OptTrySlicedVbiOutFormat: { bool foundOff = false; v4l2_format *fmt = &vbi_fmt; if (ch == OptSetSlicedVbiOutFormat || ch == OptTrySlicedVbiOutFormat) fmt = &vbi_fmt_out; fmt->fmt.sliced.service_set = 0; subs = optarg; while (*subs != '\0') { static const char *const subopts[] = { "off", "teletext", "cc", "wss", "vps", NULL }; switch (parse_subopt(&subs, subopts, &value)) { case 0: foundOff = true; break; case 1: fmt->fmt.sliced.service_set |= V4L2_SLICED_TELETEXT_B; break; case 2: fmt->fmt.sliced.service_set |= V4L2_SLICED_CAPTION_525; break; case 3: fmt->fmt.sliced.service_set |= V4L2_SLICED_WSS_625; break; case 4: fmt->fmt.sliced.service_set |= V4L2_SLICED_VPS; break; } } if (foundOff && fmt->fmt.sliced.service_set) { fprintf(stderr, "Sliced VBI mode 'off' cannot be combined with other modes\n"); usage(); return 1; } break; } case OptSetJpegComp: { subs = optarg; while (*subs != '\0') { static const char *const subopts[] = { "app0", "app1", "app2", "app3", "app4", "app5", "app6", "app7", "app8", "app9", "appa", "appb", "appc", "appd", "appe", "appf", "quality", "markers", "comment", NULL }; int len; int opt = parse_subopt(&subs, subopts, &value); switch (opt) { case 16: jpegcomp.quality = strtol(value, 0L, 0); break; case 17: if (strstr(value, "dht")) jpegcomp.jpeg_markers |= V4L2_JPEG_MARKER_DHT; if (strstr(value, "dqt")) jpegcomp.jpeg_markers |= V4L2_JPEG_MARKER_DQT; if (strstr(value, "dri")) jpegcomp.jpeg_markers |= V4L2_JPEG_MARKER_DRI; break; case 18: len = strlen(value); if (len > sizeof(jpegcomp.COM_data) - 1) len = sizeof(jpegcomp.COM_data) - 1; jpegcomp.COM_len = len; memcpy(jpegcomp.COM_data, value, len); jpegcomp.COM_data[len] = '\0'; break; default: if (opt < 0 || opt > 15) break; len = strlen(value); if (len > sizeof(jpegcomp.APP_data) - 1) len = sizeof(jpegcomp.APP_data) - 1; if (jpegcomp.APP_len) { fprintf(stderr, "Only one APP segment can be set\n"); break; } jpegcomp.APP_len = len; memcpy(jpegcomp.APP_data, value, len); jpegcomp.APP_data[len] = '\0'; jpegcomp.APPn = opt; break; } } break; } case OptListDevices: list_devices(); break; case ':': fprintf(stderr, "Option `%s' requires a value\n", argv[optind]); usage(); return 1; case '?': fprintf(stderr, "Unknown argument `%s'\n", argv[optind]); usage(); return 1; } } if (optind < argc) { printf("unknown arguments: "); while (optind < argc) printf("%s ", argv[optind++]); printf("\n"); usage(); return 1; } if ((fd = open(device, O_RDWR)) < 0) { fprintf(stderr, "Failed to open %s: %s\n", device, strerror(errno)); exit(1); } verbose = options[OptVerbose]; doioctl(fd, VIDIOC_QUERYCAP, &vcap, "VIDIOC_QUERYCAP"); capabilities = vcap.capabilities; find_controls(fd); for (ctrl_get_list::iterator iter = get_ctrls.begin(); iter != get_ctrls.end(); ++iter) { if (ctrl_str2id.find(*iter) == ctrl_str2id.end()) { fprintf(stderr, "unknown control '%s'\n", (*iter).c_str()); exit(1); } } for (ctrl_set_map::iterator iter = set_ctrls.begin(); iter != set_ctrls.end(); ++iter) { if (ctrl_str2id.find(iter->first) == ctrl_str2id.end()) { fprintf(stderr, "unknown control '%s'\n", iter->first.c_str()); exit(1); } } if (options[OptAll]) { options[OptGetVideoFormat] = 1; options[OptGetCrop] = 1; options[OptGetVideoOutFormat] = 1; options[OptGetDriverInfo] = 1; options[OptGetInput] = 1; options[OptGetOutput] = 1; options[OptGetAudioInput] = 1; options[OptGetAudioOutput] = 1; options[OptGetStandard] = 1; options[OptGetFreq] = 1; options[OptGetTuner] = 1; options[OptGetOverlayFormat] = 1; options[OptGetOutputOverlayFormat] = 1; options[OptGetVbiFormat] = 1; options[OptGetVbiOutFormat] = 1; options[OptGetSlicedVbiFormat] = 1; options[OptGetSlicedVbiOutFormat] = 1; options[OptGetFBuf] = 1; options[OptGetCropCap] = 1; options[OptGetOutputCropCap] = 1; options[OptGetJpegComp] = 1; options[OptSilent] = 1; } /* Information Opts */ if (options[OptGetDriverInfo]) { printf("Driver Info:\n"); printf("\tDriver name : %s\n", vcap.driver); printf("\tCard type : %s\n", vcap.card); printf("\tBus info : %s\n", vcap.bus_info); printf("\tDriver version: %d\n", vcap.version); printf("\tCapabilities : 0x%08X\n", vcap.capabilities); printf("%s", cap2s(vcap.capabilities).c_str()); } /* Set options */ if (options[OptStreamOff]) { int dummy = 0; doioctl(fd, VIDIOC_STREAMOFF, &dummy, "VIDIOC_STREAMOFF"); } if (options[OptSetFreq]) { double fac = 16; if (doioctl(fd, VIDIOC_G_TUNER, &tuner, "VIDIOC_G_TUNER") == 0) { fac = (tuner.capability & V4L2_TUNER_CAP_LOW) ? 16000 : 16; } vf.tuner = 0; vf.type = tuner.type; vf.frequency = __u32(freq * fac); if (doioctl(fd, VIDIOC_S_FREQUENCY, &vf, "VIDIOC_S_FREQUENCY") == 0) printf("Frequency set to %d (%f MHz)\n", vf.frequency, vf.frequency / fac); } if (options[OptSetStandard]) { if (std & (1ULL << 63)) { vs.index = std & 0xffff; if (ioctl(fd, VIDIOC_ENUMSTD, &vs) >= 0) { std = vs.id; } } if (doioctl(fd, VIDIOC_S_STD, &std, "VIDIOC_S_STD") == 0) printf("Standard set to %08llx\n", (unsigned long long)std); } if (options[OptSetInput]) { if (doioctl(fd, VIDIOC_S_INPUT, &input, "VIDIOC_S_INPUT") == 0) { printf("Video input set to %d", input); vin.index = input; if (ioctl(fd, VIDIOC_ENUMINPUT, &vin) >= 0) printf(" (%s)", vin.name); printf("\n"); } } if (options[OptSetOutput]) { if (doioctl(fd, VIDIOC_S_OUTPUT, &output, "VIDIOC_S_OUTPUT") == 0) printf("Output set to %d\n", output); } if (options[OptSetAudioInput]) { if (doioctl(fd, VIDIOC_S_AUDIO, &vaudio, "VIDIOC_S_AUDIO") == 0) printf("Audio input set to %d\n", vaudio.index); } if (options[OptSetAudioOutput]) { if (doioctl(fd, VIDIOC_S_AUDOUT, &vaudout, "VIDIOC_S_AUDOUT") == 0) printf("Audio output set to %d\n", vaudout.index); } if (options[OptSetTuner]) { struct v4l2_tuner vt; memset(&vt, 0, sizeof(struct v4l2_tuner)); if (doioctl(fd, VIDIOC_G_TUNER, &vt, "VIDIOC_G_TUNER") == 0) { vt.audmode = mode; doioctl(fd, VIDIOC_S_TUNER, &vt, "VIDIOC_S_TUNER"); } } if (options[OptSetVideoFormat] || options[OptTryVideoFormat]) { struct v4l2_format in_vfmt; in_vfmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (doioctl(fd, VIDIOC_G_FMT, &in_vfmt, "VIDIOC_G_FMT") == 0) { if (set_fmts & FmtWidth) in_vfmt.fmt.pix.width = vfmt.fmt.pix.width; if (set_fmts & FmtHeight) in_vfmt.fmt.pix.height = vfmt.fmt.pix.height; if (set_fmts & FmtPixelFormat) { in_vfmt.fmt.pix.pixelformat = vfmt.fmt.pix.pixelformat; if (in_vfmt.fmt.pix.pixelformat < 256) { struct v4l2_fmtdesc fmt; fmt.index = in_vfmt.fmt.pix.pixelformat; fmt.type = in_vfmt.type; if (doioctl(fd, VIDIOC_ENUM_FMT, &fmt, "VIDIOC_ENUM_FMT")) goto set_vid_fmt_error; in_vfmt.fmt.pix.pixelformat = fmt.pixelformat; } } if (options[OptSetVideoFormat]) ret = doioctl(fd, VIDIOC_S_FMT, &in_vfmt, "VIDIOC_S_FMT"); else ret = doioctl(fd, VIDIOC_TRY_FMT, &in_vfmt, "VIDIOC_TRY_FMT"); if (ret == 0 && verbose) printfmt(in_vfmt); } } set_vid_fmt_error: if (options[OptSetVideoOutFormat] || options[OptTryVideoOutFormat]) { struct v4l2_format in_vfmt; in_vfmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; if (doioctl(fd, VIDIOC_G_FMT, &in_vfmt, "VIDIOC_G_FMT") == 0) { if (set_fmts_out & FmtWidth) in_vfmt.fmt.pix.width = vfmt_out.fmt.pix.width; if (set_fmts_out & FmtHeight) in_vfmt.fmt.pix.height = vfmt_out.fmt.pix.height; if (options[OptSetVideoOutFormat]) ret = doioctl(fd, VIDIOC_S_FMT, &in_vfmt, "VIDIOC_S_FMT"); else ret = doioctl(fd, VIDIOC_TRY_FMT, &in_vfmt, "VIDIOC_TRY_FMT"); if (ret == 0 && verbose) printfmt(in_vfmt); } } if (options[OptSetSlicedVbiFormat] || options[OptTrySlicedVbiFormat]) { vbi_fmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE; if (options[OptSetSlicedVbiFormat]) ret = doioctl(fd, VIDIOC_S_FMT, &vbi_fmt, "VIDIOC_S_FMT"); else ret = doioctl(fd, VIDIOC_TRY_FMT, &vbi_fmt, "VIDIOC_TRY_FMT"); if (ret == 0 && verbose) printfmt(vbi_fmt); } if (options[OptSetSlicedVbiOutFormat] || options[OptTrySlicedVbiOutFormat]) { vbi_fmt_out.type = V4L2_BUF_TYPE_SLICED_VBI_OUTPUT; if (options[OptSetSlicedVbiOutFormat]) ret = doioctl(fd, VIDIOC_S_FMT, &vbi_fmt_out, "VIDIOC_S_FMT"); else ret = doioctl(fd, VIDIOC_TRY_FMT, &vbi_fmt_out, "VIDIOC_TRY_FMT"); if (ret == 0 && verbose) printfmt(vbi_fmt_out); } if (options[OptSetOverlayFormat] || options[OptTryOverlayFormat]) { struct v4l2_format fmt; fmt.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; if (doioctl(fd, VIDIOC_G_FMT, &fmt, "VIDIOC_G_FMT") == 0) { if (set_overlay_fmt & FmtChromaKey) fmt.fmt.win.chromakey = overlay_fmt.fmt.win.chromakey; if (set_overlay_fmt & FmtGlobalAlpha) fmt.fmt.win.global_alpha = overlay_fmt.fmt.win.global_alpha; if (set_overlay_fmt & FmtLeft) fmt.fmt.win.w.left = overlay_fmt.fmt.win.w.left; if (set_overlay_fmt & FmtTop) fmt.fmt.win.w.top = overlay_fmt.fmt.win.w.top; if (set_overlay_fmt & FmtWidth) fmt.fmt.win.w.width = overlay_fmt.fmt.win.w.width; if (set_overlay_fmt & FmtHeight) fmt.fmt.win.w.height = overlay_fmt.fmt.win.w.height; if (set_overlay_fmt & FmtField) fmt.fmt.win.field = overlay_fmt.fmt.win.field; if (options[OptSetOverlayFormat]) ret = doioctl(fd, VIDIOC_S_FMT, &fmt, "VIDIOC_S_FMT"); else ret = doioctl(fd, VIDIOC_TRY_FMT, &fmt, "VIDIOC_TRY_FMT"); if (ret == 0 && verbose) printfmt(fmt); } } if (options[OptSetOutputOverlayFormat] || options[OptTryOutputOverlayFormat]) { struct v4l2_format fmt; fmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY; if (doioctl(fd, VIDIOC_G_FMT, &fmt, "VIDIOC_G_FMT") == 0) { if (set_overlay_fmt_out & FmtChromaKey) fmt.fmt.win.chromakey = overlay_fmt_out.fmt.win.chromakey; if (set_overlay_fmt_out & FmtGlobalAlpha) fmt.fmt.win.global_alpha = overlay_fmt_out.fmt.win.global_alpha; if (set_overlay_fmt_out & FmtLeft) fmt.fmt.win.w.left = overlay_fmt_out.fmt.win.w.left; if (set_overlay_fmt_out & FmtTop) fmt.fmt.win.w.top = overlay_fmt_out.fmt.win.w.top; if (set_overlay_fmt_out & FmtWidth) fmt.fmt.win.w.width = overlay_fmt_out.fmt.win.w.width; if (set_overlay_fmt_out & FmtHeight) fmt.fmt.win.w.height = overlay_fmt_out.fmt.win.w.height; if (set_overlay_fmt_out & FmtField) fmt.fmt.win.field = overlay_fmt_out.fmt.win.field; if (options[OptSetOutputOverlayFormat]) ret = doioctl(fd, VIDIOC_S_FMT, &fmt, "VIDIOC_S_FMT"); else ret = doioctl(fd, VIDIOC_TRY_FMT, &fmt, "VIDIOC_TRY_FMT"); if (ret == 0 && verbose) printfmt(fmt); } } if (options[OptSetFBuf]) { struct v4l2_framebuffer fb; if (doioctl(fd, VIDIOC_G_FBUF, &fb, "VIDIOC_G_FBUF") == 0) { fb.flags &= ~set_fbuf; fb.flags |= fbuf.flags; doioctl(fd, VIDIOC_S_FBUF, &fb, "VIDIOC_S_FBUF"); } } if (options[OptSetJpegComp]) { doioctl(fd, VIDIOC_S_JPEGCOMP, &jpegcomp, "VIDIOC_S_JPEGCOMP"); } if (options[OptOverlay]) { doioctl(fd, VIDIOC_OVERLAY, &overlay, "VIDIOC_OVERLAY"); } if (options[OptSetCrop]) { do_crop(fd, set_crop, vcrop, V4L2_BUF_TYPE_VIDEO_CAPTURE); } if (options[OptSetOutputCrop]) { do_crop(fd, set_crop_out, vcrop_out, V4L2_BUF_TYPE_VIDEO_OUTPUT); } if (options[OptSetOverlayCrop]) { do_crop(fd, set_crop_overlay, vcrop_overlay, V4L2_BUF_TYPE_VIDEO_OVERLAY); } if (options[OptSetOutputOverlayCrop]) { do_crop(fd, set_crop_out_overlay, vcrop_out_overlay, V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY); } if (options[OptSetCtrl] && !set_ctrls.empty()) { struct v4l2_ext_controls ctrls = { 0 }; for (ctrl_set_map::iterator iter = set_ctrls.begin(); iter != set_ctrls.end(); ++iter) { struct v4l2_ext_control ctrl = { 0 }; ctrl.id = ctrl_str2id[iter->first]; ctrl.value = strtol(iter->second.c_str(), NULL, 0); if (V4L2_CTRL_ID2CLASS(ctrl.id) == V4L2_CTRL_CLASS_MPEG) mpeg_ctrls.push_back(ctrl); else user_ctrls.push_back(ctrl); } for (unsigned i = 0; i < user_ctrls.size(); i++) { struct v4l2_control ctrl; ctrl.id = user_ctrls[i].id; ctrl.value = user_ctrls[i].value; if (doioctl(fd, VIDIOC_S_CTRL, &ctrl, "VIDIOC_S_CTRL")) { fprintf(stderr, "%s: %s\n", ctrl_id2str[ctrl.id].c_str(), strerror(errno)); } } if (mpeg_ctrls.size()) { ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG; ctrls.count = mpeg_ctrls.size(); ctrls.controls = &mpeg_ctrls[0]; if (doioctl(fd, VIDIOC_S_EXT_CTRLS, &ctrls, "VIDIOC_S_EXT_CTRLS")) { if (ctrls.error_idx >= ctrls.count) { fprintf(stderr, "Error setting MPEG controls: %s\n", strerror(errno)); } else { fprintf(stderr, "%s: %s\n", ctrl_id2str[mpeg_ctrls[ctrls.error_idx].id].c_str(), strerror(errno)); } } } } /* Get options */ if (options[OptGetVideoFormat]) { vfmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (doioctl(fd, VIDIOC_G_FMT, &vfmt, "VIDIOC_G_FMT") == 0) printfmt(vfmt); } if (options[OptGetVideoOutFormat]) { vfmt_out.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; if (doioctl(fd, VIDIOC_G_FMT, &vfmt_out, "VIDIOC_G_FMT") == 0) printfmt(vfmt_out); } if (options[OptGetOverlayFormat]) { struct v4l2_format fmt; fmt.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; if (doioctl(fd, VIDIOC_G_FMT, &fmt, "VIDIOC_G_FMT") == 0) printfmt(fmt); } if (options[OptGetOutputOverlayFormat]) { struct v4l2_format fmt; fmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY; if (doioctl(fd, VIDIOC_G_FMT, &fmt, "VIDIOC_G_FMT") == 0) printfmt(fmt); } if (options[OptGetSlicedVbiFormat]) { vbi_fmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE; if (doioctl(fd, VIDIOC_G_FMT, &vbi_fmt, "VIDIOC_G_FMT") == 0) printfmt(vbi_fmt); } if (options[OptGetSlicedVbiOutFormat]) { vbi_fmt_out.type = V4L2_BUF_TYPE_SLICED_VBI_OUTPUT; if (doioctl(fd, VIDIOC_G_FMT, &vbi_fmt_out, "VIDIOC_G_FMT") == 0) printfmt(vbi_fmt_out); } if (options[OptGetVbiFormat]) { raw_fmt.type = V4L2_BUF_TYPE_VBI_CAPTURE; if (doioctl(fd, VIDIOC_G_FMT, &raw_fmt, "VIDIOC_G_FMT") == 0) printfmt(raw_fmt); } if (options[OptGetVbiOutFormat]) { raw_fmt_out.type = V4L2_BUF_TYPE_VBI_OUTPUT; if (doioctl(fd, VIDIOC_G_FMT, &raw_fmt_out, "VIDIOC_G_FMT") == 0) printfmt(raw_fmt_out); } if (options[OptGetFBuf]) { struct v4l2_framebuffer fb; if (doioctl(fd, VIDIOC_G_FBUF, &fb, "VIDIOC_G_FBUF") == 0) printfbuf(fb); } if (options[OptGetJpegComp]) { struct v4l2_jpegcompression jc; if (doioctl(fd, VIDIOC_G_JPEGCOMP, &jc, "VIDIOC_G_JPEGCOMP") == 0) printjpegcomp(jc); } if (options[OptGetCropCap]) { struct v4l2_cropcap cropcap; cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (doioctl(fd, VIDIOC_CROPCAP, &cropcap, "VIDIOC_CROPCAP") == 0) printcropcap(cropcap); } if (options[OptGetOutputCropCap]) { struct v4l2_cropcap cropcap; cropcap.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; if (doioctl(fd, VIDIOC_CROPCAP, &cropcap, "VIDIOC_CROPCAP") == 0) printcropcap(cropcap); } if (options[OptGetOverlayCropCap]) { struct v4l2_cropcap cropcap; cropcap.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; if (doioctl(fd, VIDIOC_CROPCAP, &cropcap, "VIDIOC_CROPCAP") == 0) printcropcap(cropcap); } if (options[OptGetOutputOverlayCropCap]) { struct v4l2_cropcap cropcap; cropcap.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY; if (doioctl(fd, VIDIOC_CROPCAP, &cropcap, "VIDIOC_CROPCAP") == 0) printcropcap(cropcap); } if (options[OptGetCrop]) { struct v4l2_crop crop; crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (doioctl(fd, VIDIOC_G_CROP, &crop, "VIDIOC_G_CROP") == 0) printcrop(crop); } if (options[OptGetOutputCrop]) { struct v4l2_crop crop; crop.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; if (doioctl(fd, VIDIOC_G_CROP, &crop, "VIDIOC_G_CROP") == 0) printcrop(crop); } if (options[OptGetOverlayCrop]) { struct v4l2_crop crop; crop.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; if (doioctl(fd, VIDIOC_G_CROP, &crop, "VIDIOC_G_CROP") == 0) printcrop(crop); } if (options[OptGetOutputOverlayCrop]) { struct v4l2_crop crop; crop.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY; if (doioctl(fd, VIDIOC_G_CROP, &crop, "VIDIOC_G_CROP") == 0) printcrop(crop); } if (options[OptGetInput]) { if (doioctl(fd, VIDIOC_G_INPUT, &input, "VIDIOC_G_INPUT") == 0) { printf("Video input : %d", input); vin.index = input; if (ioctl(fd, VIDIOC_ENUMINPUT, &vin) >= 0) printf(" (%s)", vin.name); printf("\n"); } } if (options[OptGetOutput]) { if (doioctl(fd, VIDIOC_G_OUTPUT, &output, "VIDIOC_G_OUTPUT") == 0) { printf("Video output: %d", output); vout.index = output; if (ioctl(fd, VIDIOC_ENUMOUTPUT, &vout) >= 0) { printf(" (%s)", vout.name); } printf("\n"); } } if (options[OptGetAudioInput]) { if (doioctl(fd, VIDIOC_G_AUDIO, &vaudio, "VIDIOC_G_AUDIO") == 0) printf("Audio input : %d (%s)\n", vaudio.index, vaudio.name); } if (options[OptGetAudioOutput]) { if (doioctl(fd, VIDIOC_G_AUDOUT, &vaudout, "VIDIOC_G_AUDOUT") == 0) printf("Audio output: %d (%s)\n", vaudout.index, vaudout.name); } if (options[OptGetFreq]) { double fac = 16; if (doioctl(fd, VIDIOC_G_TUNER, &tuner, "VIDIOC_G_TUNER") == 0) { fac = (tuner.capability & V4L2_TUNER_CAP_LOW) ? 16000 : 16; } vf.tuner = 0; if (doioctl(fd, VIDIOC_G_FREQUENCY, &vf, "VIDIOC_G_FREQUENCY") == 0) printf("Frequency: %d (%f MHz)\n", vf.frequency, vf.frequency / fac); } if (options[OptGetStandard]) { if (doioctl(fd, VIDIOC_G_STD, &std, "VIDIOC_G_STD") == 0) { static const char *pal[] = { "B", "B1", "G", "H", "I", "D", "D1", "K", "M", "N", "Nc", "60", NULL }; static const char *ntsc[] = { "M", "M-JP", "443", "M-KR", NULL }; static const char *secam[] = { "B", "D", "G", "H", "K", "K1", "L", "Lc", NULL }; static const char *atsc[] = { "ATSC-8-VSB", "ATSC-16-VSB", NULL }; printf("Video Standard = 0x%08llx\n", (unsigned long long)std); if (std & 0xfff) { print_std("PAL", pal, std); } if (std & 0xf000) { print_std("NTSC", ntsc, std >> 12); } if (std & 0xff0000) { print_std("SECAM", secam, std >> 16); } if (std & 0xf000000) { print_std("ATSC/HDTV", atsc, std >> 24); } } } if (options[OptGetCtrl] && !get_ctrls.empty()) { struct v4l2_ext_controls ctrls = { 0 }; mpeg_ctrls.clear(); user_ctrls.clear(); for (ctrl_get_list::iterator iter = get_ctrls.begin(); iter != get_ctrls.end(); ++iter) { struct v4l2_ext_control ctrl = { 0 }; ctrl.id = ctrl_str2id[*iter]; if (V4L2_CTRL_ID2CLASS(ctrl.id) == V4L2_CTRL_CLASS_MPEG) mpeg_ctrls.push_back(ctrl); else user_ctrls.push_back(ctrl); } for (unsigned i = 0; i < user_ctrls.size(); i++) { struct v4l2_control ctrl; ctrl.id = user_ctrls[i].id; doioctl(fd, VIDIOC_G_CTRL, &ctrl, "VIDIOC_G_CTRL"); printf("%s: %d\n", ctrl_id2str[ctrl.id].c_str(), ctrl.value); } if (mpeg_ctrls.size()) { ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG; ctrls.count = mpeg_ctrls.size(); ctrls.controls = &mpeg_ctrls[0]; doioctl(fd, VIDIOC_G_EXT_CTRLS, &ctrls, "VIDIOC_G_EXT_CTRLS"); for (unsigned i = 0; i < mpeg_ctrls.size(); i++) { struct v4l2_ext_control ctrl = mpeg_ctrls[i]; printf("%s: %d\n", ctrl_id2str[ctrl.id].c_str(), ctrl.value); } } } if (options[OptGetTuner]) { struct v4l2_tuner vt; memset(&vt, 0, sizeof(struct v4l2_tuner)); if (doioctl(fd, VIDIOC_G_TUNER, &vt, "VIDIOC_G_TUNER") == 0) { printf("Tuner:\n"); printf("\tName : %s\n", vt.name); printf("\tCapabilities : %s\n", tcap2s(vt.capability).c_str()); if (vt.capability & V4L2_TUNER_CAP_LOW) printf("\tFrequency range : %.1f MHz - %.1f MHz\n", vt.rangelow / 16000.0, vt.rangehigh / 16000.0); else printf("\tFrequency range : %.1f MHz - %.1f MHz\n", vt.rangelow / 16.0, vt.rangehigh / 16.0); printf("\tSignal strength/AFC : %d%%/%d\n", (int)(vt.signal / 655.35), vt.afc); printf("\tCurrent audio mode : %s\n", audmode2s(vt.audmode)); printf("\tAvailable subchannels: %s\n", rxsubchans2s(vt.rxsubchans).c_str()); } } if (options[OptLogStatus]) { static char buf[40960]; int len; if (doioctl(fd, VIDIOC_LOG_STATUS, NULL, "VIDIOC_LOG_STATUS") == 0) { printf("\nStatus Log:\n\n"); len = klogctl(3, buf, sizeof(buf) - 1); if (len >= 0) { char *p = buf; char *q; buf[len] = 0; while ((q = strstr(p, "START STATUS CARD #"))) { p = q + 1; } if (p) { while (p > buf && *p != '<') p--; q = p; while ((q = strstr(q, "<6>"))) { memcpy(q, " ", 3); } printf("%s", p); } } } } /* List options */ if (options[OptListInputs]) { vin.index = 0; printf("ioctl: VIDIOC_ENUMINPUT\n"); while (ioctl(fd, VIDIOC_ENUMINPUT, &vin) >= 0) { if (vin.index) printf("\n"); printf("\tInput : %d\n", vin.index); printf("\tName : %s\n", vin.name); printf("\tType : 0x%08X\n", vin.type); printf("\tAudioset: 0x%08X\n", vin.audioset); printf("\tTuner : 0x%08X\n", vin.tuner); printf("\tStandard: 0x%016llX ( ", (unsigned long long)vin.std); if (vin.std & 0x000FFF) printf("PAL "); // hack if (vin.std & 0x00F000) printf("NTSC "); // hack if (vin.std & 0x7F0000) printf("SECAM "); // hack printf(")\n"); printf("\tStatus : %d\n", vin.status); vin.index++; } } if (options[OptListOutputs]) { vout.index = 0; printf("ioctl: VIDIOC_ENUMOUTPUT\n"); while (ioctl(fd, VIDIOC_ENUMOUTPUT, &vout) >= 0) { if (vout.index) printf("\n"); printf("\tOutput : %d\n", vout.index); printf("\tName : %s\n", vout.name); printf("\tType : 0x%08X\n", vout.type); printf("\tAudioset: 0x%08X\n", vout.audioset); printf("\tStandard: 0x%016llX ( ", (unsigned long long)vout.std); if (vout.std & 0x000FFF) printf("PAL "); // hack if (vout.std & 0x00F000) printf("NTSC "); // hack if (vout.std & 0x7F0000) printf("SECAM "); // hack printf(")\n"); vout.index++; } } if (options[OptListAudioInputs]) { struct v4l2_audio vaudio; /* list audio inputs */ vaudio.index = 0; printf("ioctl: VIDIOC_ENUMAUDIO\n"); while (ioctl(fd, VIDIOC_ENUMAUDIO, &vaudio) >= 0) { if (vaudio.index) printf("\n"); printf("\tInput : %d\n", vaudio.index); printf("\tName : %s\n", vaudio.name); vaudio.index++; } } if (options[OptListAudioOutputs]) { struct v4l2_audioout vaudio; /* list audio outputs */ vaudio.index = 0; printf("ioctl: VIDIOC_ENUMAUDOUT\n"); while (ioctl(fd, VIDIOC_ENUMAUDOUT, &vaudio) >= 0) { if (vaudio.index) printf("\n"); printf("\tOutput : %d\n", vaudio.index); printf("\tName : %s\n", vaudio.name); vaudio.index++; } } if (options[OptListStandards]) { printf("ioctl: VIDIOC_ENUMSTD\n"); vs.index = 0; while (ioctl(fd, VIDIOC_ENUMSTD, &vs) >= 0) { if (vs.index) printf("\n"); printf("\tIndex : %d\n", vs.index); printf("\tID : 0x%016llX\n", (unsigned long long)vs.id); printf("\tName : %s\n", vs.name); printf("\tFrame period: %d/%d\n", vs.frameperiod.numerator, vs.frameperiod.denominator); printf("\tFrame lines : %d\n", vs.framelines); vs.index++; } } if (options[OptListFormats]) { printf("ioctl: VIDIOC_ENUM_FMT\n"); print_video_formats(fd, V4L2_BUF_TYPE_VIDEO_CAPTURE); print_video_formats(fd, V4L2_BUF_TYPE_VIDEO_OUTPUT); print_video_formats(fd, V4L2_BUF_TYPE_VIDEO_OVERLAY); } if (options[OptGetSlicedVbiCap]) { struct v4l2_sliced_vbi_cap cap; cap.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE; if (doioctl(fd, VIDIOC_G_SLICED_VBI_CAP, &cap, "VIDIOC_G_SLICED_VBI_CAP") == 0) { print_sliced_vbi_cap(cap); } } if (options[OptGetSlicedVbiOutCap]) { struct v4l2_sliced_vbi_cap cap; cap.type = V4L2_BUF_TYPE_SLICED_VBI_OUTPUT; if (doioctl(fd, VIDIOC_G_SLICED_VBI_CAP, &cap, "VIDIOC_G_SLICED_VBI_CAP") == 0) { print_sliced_vbi_cap(cap); } } if (options[OptListCtrlsMenus]) { list_controls(fd, 1); } if (options[OptListCtrls]) { list_controls(fd, 0); } if (options[OptStreamOn]) { int dummy = 0; doioctl(fd, VIDIOC_STREAMON, &dummy, "VIDIOC_STREAMON"); } close(fd); exit(app_result); } ivtv-utils-1.4.1/utils/cx25840ctl/0000775000076400007640000000000011355717714015220 5ustar andyandyivtv-utils-1.4.1/utils/cx25840ctl/i2c-dev.h0000664000076400007640000003012411355717527016624 0ustar andyandy/* i2c-dev.h - i2c-bus driver, char device interface Copyright (C) 1995-97 Simon G. Vogl Copyright (C) 1998-99 Frodo Looijaard This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* $Id: i2c-dev.h,v 1.7 2003/01/21 20:01:26 kmalkki Exp $ */ #ifndef LIB_I2CDEV_H #define LIB_I2CDEV_H #include #include /* -- i2c.h -- */ /* * I2C Message - used for pure i2c transaction, also from /dev interface */ struct i2c_msg { __u16 addr; /* slave address */ unsigned short flags; #define I2C_M_TEN 0x10 /* we have a ten bit chip address */ #define I2C_M_RD 0x01 #define I2C_M_NOSTART 0x4000 #define I2C_M_REV_DIR_ADDR 0x2000 #define I2C_M_IGNORE_NAK 0x1000 #define I2C_M_NO_RD_ACK 0x0800 short len; /* msg length */ char *buf; /* pointer to msg data */ int err; short done; }; /* To determine what functionality is present */ #define I2C_FUNC_I2C 0x00000001 #define I2C_FUNC_10BIT_ADDR 0x00000002 #define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */ #define I2C_FUNC_SMBUS_HWPEC_CALC 0x00000008 /* SMBus 2.0 */ #define I2C_FUNC_SMBUS_READ_WORD_DATA_PEC 0x00000800 /* SMBus 2.0 */ #define I2C_FUNC_SMBUS_WRITE_WORD_DATA_PEC 0x00001000 /* SMBus 2.0 */ #define I2C_FUNC_SMBUS_PROC_CALL_PEC 0x00002000 /* SMBus 2.0 */ #define I2C_FUNC_SMBUS_BLOCK_PROC_CALL_PEC 0x00004000 /* SMBus 2.0 */ #define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */ #define I2C_FUNC_SMBUS_QUICK 0x00010000 #define I2C_FUNC_SMBUS_READ_BYTE 0x00020000 #define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000 #define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000 #define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000 #define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000 #define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000 #define I2C_FUNC_SMBUS_PROC_CALL 0x00800000 #define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000 #define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000 #define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */ #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */ #define I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 0x10000000 /* I2C-like block xfer */ #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2 0x20000000 /* w/ 2-byte reg. addr. */ #define I2C_FUNC_SMBUS_READ_BLOCK_DATA_PEC 0x40000000 /* SMBus 2.0 */ #define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA_PEC 0x80000000 /* SMBus 2.0 */ #define I2C_FUNC_SMBUS_BYTE I2C_FUNC_SMBUS_READ_BYTE | \ I2C_FUNC_SMBUS_WRITE_BYTE #define I2C_FUNC_SMBUS_BYTE_DATA I2C_FUNC_SMBUS_READ_BYTE_DATA | \ I2C_FUNC_SMBUS_WRITE_BYTE_DATA #define I2C_FUNC_SMBUS_WORD_DATA I2C_FUNC_SMBUS_READ_WORD_DATA | \ I2C_FUNC_SMBUS_WRITE_WORD_DATA #define I2C_FUNC_SMBUS_BLOCK_DATA I2C_FUNC_SMBUS_READ_BLOCK_DATA | \ I2C_FUNC_SMBUS_WRITE_BLOCK_DATA #define I2C_FUNC_SMBUS_I2C_BLOCK I2C_FUNC_SMBUS_READ_I2C_BLOCK | \ I2C_FUNC_SMBUS_WRITE_I2C_BLOCK #define I2C_FUNC_SMBUS_I2C_BLOCK_2 I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 | \ I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2 #define I2C_FUNC_SMBUS_BLOCK_DATA_PEC I2C_FUNC_SMBUS_READ_BLOCK_DATA_PEC | \ I2C_FUNC_SMBUS_WRITE_BLOCK_DATA_PEC #define I2C_FUNC_SMBUS_WORD_DATA_PEC I2C_FUNC_SMBUS_READ_WORD_DATA_PEC | \ I2C_FUNC_SMBUS_WRITE_WORD_DATA_PEC #define I2C_FUNC_SMBUS_READ_BYTE_PEC I2C_FUNC_SMBUS_READ_BYTE_DATA #define I2C_FUNC_SMBUS_WRITE_BYTE_PEC I2C_FUNC_SMBUS_WRITE_BYTE_DATA #define I2C_FUNC_SMBUS_READ_BYTE_DATA_PEC I2C_FUNC_SMBUS_READ_WORD_DATA #define I2C_FUNC_SMBUS_WRITE_BYTE_DATA_PEC I2C_FUNC_SMBUS_WRITE_WORD_DATA #define I2C_FUNC_SMBUS_BYTE_PEC I2C_FUNC_SMBUS_BYTE_DATA #define I2C_FUNC_SMBUS_BYTE_DATA_PEC I2C_FUNC_SMBUS_WORD_DATA #define I2C_FUNC_SMBUS_EMUL I2C_FUNC_SMBUS_QUICK | \ I2C_FUNC_SMBUS_BYTE | \ I2C_FUNC_SMBUS_BYTE_DATA | \ I2C_FUNC_SMBUS_WORD_DATA | \ I2C_FUNC_SMBUS_PROC_CALL | \ I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \ I2C_FUNC_SMBUS_WRITE_BLOCK_DATA_PEC | \ I2C_FUNC_SMBUS_I2C_BLOCK /* * Data for SMBus Messages */ #define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */ #define I2C_SMBUS_I2C_BLOCK_MAX 32 /* Not specified but we use same structure */ union i2c_smbus_data { __u8 byte; __u16 word; __u8 block[I2C_SMBUS_BLOCK_MAX + 3]; /* block[0] is used for length */ /* one more for read length in block process call */ /* and one more for PEC */ }; /* smbus_access read or write markers */ #define I2C_SMBUS_READ 1 #define I2C_SMBUS_WRITE 0 /* SMBus transaction types (size parameter in the above functions) Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */ #define I2C_SMBUS_QUICK 0 #define I2C_SMBUS_BYTE 1 #define I2C_SMBUS_BYTE_DATA 2 #define I2C_SMBUS_WORD_DATA 3 #define I2C_SMBUS_PROC_CALL 4 #define I2C_SMBUS_BLOCK_DATA 5 #define I2C_SMBUS_I2C_BLOCK_DATA 6 #define I2C_SMBUS_BLOCK_PROC_CALL 7 /* SMBus 2.0 */ #define I2C_SMBUS_BLOCK_DATA_PEC 8 /* SMBus 2.0 */ #define I2C_SMBUS_PROC_CALL_PEC 9 /* SMBus 2.0 */ #define I2C_SMBUS_BLOCK_PROC_CALL_PEC 10 /* SMBus 2.0 */ #define I2C_SMBUS_WORD_DATA_PEC 11 /* SMBus 2.0 */ /* ----- commands for the ioctl like i2c_command call: * note that additional calls are defined in the algorithm and hw * dependent layers - these can be listed here, or see the * corresponding header files. */ /* -> bit-adapter specific ioctls */ #define I2C_RETRIES 0x0701 /* number of times a device address */ /* should be polled when not */ /* acknowledging */ #define I2C_TIMEOUT 0x0702 /* set timeout - call with int */ /* this is for i2c-dev.c */ #define I2C_SLAVE 0x0703 /* Change slave address */ /* Attn.: Slave address is 7 or 10 bits */ #define I2C_SLAVE_FORCE 0x0706 /* Change slave address */ /* Attn.: Slave address is 7 or 10 bits */ /* This changes the address, even if it */ /* is already taken! */ #define I2C_TENBIT 0x0704 /* 0 for 7 bit addrs, != 0 for 10 bit */ #define I2C_FUNCS 0x0705 /* Get the adapter functionality */ #define I2C_RDWR 0x0707 /* Combined R/W transfer (one stop only)*/ #define I2C_PEC 0x0708 /* != 0 for SMBus PEC */ #if 0 #define I2C_ACK_TEST 0x0710 /* See if a slave is at a specific address */ #endif #define I2C_SMBUS 0x0720 /* SMBus-level access */ /* -- i2c.h -- */ /* Note: 10-bit addresses are NOT supported! */ /* This is the structure as used in the I2C_SMBUS ioctl call */ struct i2c_smbus_ioctl_data { char read_write; __u8 command; int size; union i2c_smbus_data *data; }; /* This is the structure as used in the I2C_RDWR ioctl call */ struct i2c_rdwr_ioctl_data { struct i2c_msg *msgs; /* pointers to i2c_msgs */ int nmsgs; /* number of i2c_msgs */ }; static inline __s32 i2c_smbus_access(int file, char read_write, __u8 command, int size, union i2c_smbus_data *data) { struct i2c_smbus_ioctl_data args; args.read_write = read_write; args.command = command; args.size = size; args.data = data; return ioctl(file,I2C_SMBUS,&args); } static inline __s32 i2c_smbus_write_quick(int file, __u8 value) { return i2c_smbus_access(file,value,0,I2C_SMBUS_QUICK,NULL); } static inline __s32 i2c_smbus_read_byte(int file) { union i2c_smbus_data data; if (i2c_smbus_access(file,I2C_SMBUS_READ,0,I2C_SMBUS_BYTE,&data)) return -1; else return 0x0FF & data.byte; } static inline __s32 i2c_smbus_write_byte(int file, __u8 value) { return i2c_smbus_access(file,I2C_SMBUS_WRITE,value, I2C_SMBUS_BYTE,NULL); } static inline __s32 i2c_smbus_read_byte_data(int file, __u8 command) { union i2c_smbus_data data; if (i2c_smbus_access(file,I2C_SMBUS_READ,command, I2C_SMBUS_BYTE_DATA,&data)) return -1; else return 0x0FF & data.byte; } static inline __s32 i2c_smbus_write_byte_data(int file, __u8 command, __u8 value) { union i2c_smbus_data data; data.byte = value; return i2c_smbus_access(file,I2C_SMBUS_WRITE,command, I2C_SMBUS_BYTE_DATA, &data); } static inline __s32 i2c_smbus_read_word_data(int file, __u8 command) { union i2c_smbus_data data; if (i2c_smbus_access(file,I2C_SMBUS_READ,command, I2C_SMBUS_WORD_DATA,&data)) return -1; else return 0x0FFFF & data.word; } static inline __s32 i2c_smbus_write_word_data(int file, __u8 command, __u16 value) { union i2c_smbus_data data; data.word = value; return i2c_smbus_access(file,I2C_SMBUS_WRITE,command, I2C_SMBUS_WORD_DATA, &data); } static inline __s32 i2c_smbus_process_call(int file, __u8 command, __u16 value) { union i2c_smbus_data data; data.word = value; if (i2c_smbus_access(file,I2C_SMBUS_WRITE,command, I2C_SMBUS_PROC_CALL,&data)) return -1; else return 0x0FFFF & data.word; } /* Returns the number of read bytes */ static inline __s32 i2c_smbus_read_block_data(int file, __u8 command, __u8 *values) { union i2c_smbus_data data; int i; if (i2c_smbus_access(file,I2C_SMBUS_READ,command, I2C_SMBUS_BLOCK_DATA,&data)) return -1; else { for (i = 1; i <= data.block[0]; i++) values[i-1] = data.block[i]; return data.block[0]; } } static inline __s32 i2c_smbus_write_block_data(int file, __u8 command, __u8 length, __u8 *values) { union i2c_smbus_data data; int i; if (length > 32) length = 32; for (i = 1; i <= length; i++) data.block[i] = values[i-1]; data.block[0] = length; return i2c_smbus_access(file,I2C_SMBUS_WRITE,command, I2C_SMBUS_BLOCK_DATA, &data); } /* Returns the number of read bytes */ static inline __s32 i2c_smbus_read_i2c_block_data(int file, __u8 command, __u8 *values) { union i2c_smbus_data data; int i; if (i2c_smbus_access(file,I2C_SMBUS_READ,command, I2C_SMBUS_I2C_BLOCK_DATA,&data)) return -1; else { for (i = 1; i <= data.block[0]; i++) values[i-1] = data.block[i]; return data.block[0]; } } static inline __s32 i2c_smbus_write_i2c_block_data(int file, __u8 command, __u8 length, __u8 *values) { union i2c_smbus_data data; int i; if (length > 32) length = 32; for (i = 1; i <= length; i++) data.block[i] = values[i-1]; data.block[0] = length; return i2c_smbus_access(file,I2C_SMBUS_WRITE,command, I2C_SMBUS_I2C_BLOCK_DATA, &data); } /* Returns the number of read bytes */ static inline __s32 i2c_smbus_block_process_call(int file, __u8 command, __u8 length, __u8 *values) { union i2c_smbus_data data; int i; if (length > 32) length = 32; for (i = 1; i <= length; i++) data.block[i] = values[i-1]; data.block[0] = length; if (i2c_smbus_access(file,I2C_SMBUS_WRITE,command, I2C_SMBUS_BLOCK_PROC_CALL,&data)) return -1; else { for (i = 1; i <= data.block[0]; i++) values[i-1] = data.block[i]; return data.block[0]; } } #endif /* LIB_I2CDEV_H */ ivtv-utils-1.4.1/utils/cx25840ctl/cx25840-registers.h0000664000076400007640000002447411355717527020430 0ustar andyandy/* * cx25840 - register map * * This file is auto generated do not edit. * * There are non obvoius relationships between values. * * Submit errors in this file to the ivtv development mail list. * */ #ifndef __CX25840_REGISTERS_H #define __CX25840_REGISTERS_H #include #include "cx25840-settings.h" typedef enum { RC, RO, RR, RW, SC, VO } cx25840_setting_type; extern __u16 cx25840_register_info[]; extern char *cx25840_register_name[]; extern __u8 cx25840_register_default[]; typedef struct { unsigned int value; char *name; } value_map; typedef struct { __u32 location; // bit0-8 reg 9-11 start 12-16 len 17-20 type __u32 default_value; char *name; value_map *mapping; char *description; } cx25840_setting_entry; extern cx25840_setting_entry cx25840_settings[]; #define CX25840_REGISTER_ADDRESS(i) (cx25840_register_info[(i)]&0x0fff) #define CX25840_REGISTER_TYPE(i) (cx25840_register_info[(i)]>>12) #define CX25840_REGISTER_NAME(i) (cx25840_register_name[(i)]) #define CX25840_REGISTER_DEFAULT(i) (cx25840_register_default[(i)]) #define CX25840_SETTING_REGISTER_INDEX(i) ((cx25840_settings[(i)].location>>0)&0x01ff) #define CX25840_SETTING_START_BIT(i) ((cx25840_settings[(i)].location>>9)&0x0007) #define CX25840_SETTING_BIT_LENGTH(i) ((cx25840_settings[(i)].location>>12)&0x001f) #define CX25840_SETTING_TYPE(i) ((cx25840_settings[(i)].location>>17)&0x000f) #define CX25840_SETTING_DEFAULT_VALUE(i) (cx25840_settings[(i)].default_value) #define CX25840_SETTING_NAME(i) (cx25840_settings[(i)].name) #define CX25840_SETTING_MAPPING(i) (cx25840_settings[(i)].mapping) #define CX25840_SETTING_DESCRIPTION(i) (cx25840_settings[(i)].description) typedef enum { Host_Register_1, Host_Register_2, Device_ID_Low_Byte, Device_ID_High_Byte, Configuration, Video_Input_Control, AFE_Control_1, AFE_Control_2, AFE_Control_3, AFE_Control_4, Video_PLL_Integer, Video_PLL_Divider, Aux_PLL_Integer, Aux_PLL_Divider, Video_PLL_Fractional_1, Video_PLL_Fractional_2, Video_PLL_Fractional_3, Video_PLL_Fractional_4, Aux_PLL_Fractional_1, Aux_PLL_Fractional_2, Aux_PLL_Fractional_3, Aux_PLL_Fractional_4, Pin_Control_1, Pin_Control_2, Pin_Control_3, Pin_Control_4, Pin_Control_5, Pin_Control_6, Pin_Configuration_1, Pin_Configuration_2, Pin_Configuration_3, Pin_Configuration_4, Pin_Configuration_5, Pin_Configuration_6, Pin_Configuration_7, Pin_Configuration_8, Pin_Configuration_9, Pin_Configuration_10, Pin_Configuration_11, Pin_Configuration_12, Video_Count_Low, Video_Count_Mid, Video_Count_High, Audio_Lock, Audio_Count_Low, Audio_Count_Mid, Audio_Lock_2, Audio_Lock_3, Power_Control_1, Power_Control_2, AFE_Diagnostic_Control_1, AFE_Diagnostic_Control_2, AFE_Diagnostic_Control_3, AFE_Diagnostic_Control_5, AFE_Diagnostic_Control_6, AFE_Diagnostic_Control_7, AFE_Diagnostic_Control_8, PLL_Diagnostic_Control_1, PLL_Diagnostic_Control_2, DLL1_Diagnostic_Control_2, DLL1_Diagnostic_Control_3, DLL1_Diagnostic_Control_4, DLL2_Diagnostic_Control_1, DLL2_Diagnostic_Control_2, DLL2_Diagnostic_Control_3, DLL2_Diagnostic_Control_4, IR_Control_1, IR_Control_2, IR_TX_Clock_Divider_Low, IR_TX_Clock_Divider_High, IR_RX_Clock_Divider_Low, IR_RX_Clock_Divider_High, IR_TX_Carrier_Duty_Cycle, IR_Status, IR_Interrupt_Enable, IR_Low_Pass_Filter_Low, IR_Low_Pass_Filter_High, IR_FIFO_Low, IR_FIFO_High, IR_FIFO_Level, Video_Mode_Control_1, Video_Mode_Control_2, Video_Mode_Control_3, Video_Mode_Control_4, Video_Out_Control_1, Video_Out_Control_2, Video_Out_Control_3, Video_Out_Control_4, Ancillary_IDID_0, Ancillary_IDID_1, Ancillary_IDID_0_1, Ancillary_Audio_Output_Control, Copy_Protection_Status, General_Status_1, General_Status_2, Interrupt_Status_1, Interrupt_Status_2, Interrupt_Mask_1, Interrupt_Mask_2, Brightness, Contrast, Luma_Control, Horizontal_Scaling_Low, Horizontal_Scaling_Mid, Horizontal_Scaling_High, Horizontal_Scaling_Control, Vertical_Scaling_Low, Vertical_Scaling_High, Vertical_Scaling_Control, Vertical_Line_Control, Saturation_U, Saturation_V, Hue, Chroma_Control, VBI_Line_Control_1, VBI_Line_Control_2, VBI_Line_Control_3, VBI_Line_Control_4, VBI_Line_Control_5, VBI_Line_Control_6, VBI_Line_Control_7, VBI_Line_Control_8, VBI_Line_Control_9, VBI_Line_Control_10, VBI_Line_Control_11, VBI_Line_Control_12, VBI_Line_Control_13, VBI_Line_Control_14, VBI_Line_Control_15, VBI_Line_Control_16, VBI_Line_Control_17, VBI_Frame_Code_Search_Mode, VBI_Alternate_Frame_Code_Type, VBI_Alternate_1_Frame_Code, VBI_Alternate_2_Frame_Code, VBI_Miscellaneous_Config_1, TTX_Packet_Address_1, TTX_Packet_Address_2, TTX_Packet_Address_3, VBI_1_and_2_SDID, VBI_3_SDID, VBI_FIFO_Reset, VBI_Hamming, Closed_Caption_Status, Closed_Caption_Data, GEMSTAR_1x_Status, GEMSTAR_1x_Data, GEMSTAR_2x_Status, GEMSTAR_2x_Data, WSS_Status, WSS_Data, VBI_Custom_1_Horizontal_Delay, VBI_Custom_1_Bit_Increment, VBI_Custom_1_Slice_Distance, VBI_Custom_1_Clock_Run_in_Window, VBI_Custom_1_Frame_Code_Low, VBI_Custom_1_Frame_Code_Mid, VBI_Custom_1_Frame_Code_High, VBI_Custom_1_Frame_Code_Length, VBI_Custom_1_Clock_Run_in_Period, VBI_Custom_1_Clock_Run_in_Margin_and_Length, VBI_Custom_1_Payload_Length, VBI_Custom_1_Miscellaneous, VBI_Custom_2_Horizontal_Delay, VBI_Custom_2_Bit_Increment, VBI_Custom_2_Slice_Distance, VBI_Custom_2_Clock_Run_In_Window, VBI_Custom_2_Frame_Code_Low, VBI_Custom_2_Frame_Code_Mid, VBI_Custom_2_Frame_Code_High, VBI_Custom_2_Frame_Code_Length, VBI_Custom_2_Clock_Run_in_Period, VBI_Custom_2_Clock_Run_in_Margin_and_Length, VBI_Custom_2_Payload_Length, VBI_Custom_2_Miscellaneous, VBI_Custom_3_Horizontal_Delay, VBI_Custom_3_Bit_Increment, VBI_Custom_3_Slice_Distance, VBI_Custom_3_Clock_Run_in_Window, VBI_Custom_3_Frame_Code_Low, VBI_Custom_3_Frame_Code_Mid, VBI_Custom_3_Frame_Code_High, VBI_Custom_3_Frame_Code_Length, VBI_Custom_3_Clock_Run_in_Period, VBI_Custom_3_Clock_Run_in_Margin_and_Length, VBI_Custom_3_Payload_Length, VBI_Custom_3_Miscellaneous, Horizontal_Blanking_Delay_Low, Horizontal_Blanking_Delay_High, Horizontal_Active_High, Burst_Gate_Delay, Vertical_Blanking_Delay_Low, Vertical_Blanking_Delay_High, Vertical_Active_High, Vertical_Blanking_Delay_656, SRC_Decimation_Ratio_Low, SRC_Decimation_Ratio_High, Comb_Filter_Bandwidth_Select, Comb_Filter_Enable, Subcarrier_Step_Size_Low, Subcarrier_Step_Size_Mid, Subcarrier_Step_Size_High, VBI_Offset, Field_Count_Low, Field_Count_High, Temporal_Decimation, Miscellaneous_Timing_Control, Video_Detect_Configuration, VGA_Gain_Control, AGC_Gain_Control_Low, AGC_Gain_Control_High, Digital_Front_End_Control, VGA_Sync_Control, VGA_Track_Range, VGA_Acquire_Range, DFE_Control, Backporch_Loop_Gain, DFT_Threshold, Backporch_Percent, PLL_Offset_Low, PLL_Offset_High, PLL_Indirect_Loop_Gain, PLL_Direct_Loop_Gain, Horizontal_Tracking_Loop_Indirect_Gain, Luma_Comb_Error_Limit_Max, Luma_Comb_Threshold, Chroma_Comb_Error_Limit_Max, Comb_Phase_Limit_Max, White_Crush_Increment, White_Crush_Decrement, White_Crush_Comparison_Point, Soft_Reset_Mask_1, Soft_Reset_Mask_2, Version_ID, Miscellaneous_Diagnostic_Control, Download_Address_Low_Byte, Download_Address_High_Byte, Download_Data_Control, Download_Control, Mode_Detect_Status_0, Mode_Detect_Status_1, Audio_Configuration, Preferred_Decode_Mode, Embedded_Microcontroller_Video_Format, Audio_Format_Control_0, Soft_Reset, Audio_Interrupt_Control, Audio_Interrupt_Status, Analog_AGC_Hysteresis1, Analog_AGC_Hysteresis2, Analog_AGC_Control, AFE_12DB_ENABLE, IF_SRC_Mode, Phase_Fix_Control, Dematrix_Bypass, Dematrix_Select_Control, Digital_Audio_Input_Shifter, Path1_Audio_Select_Control, Path1_AVC_Control1, Path1_AVC_Control2, Mute_Control, Path1_Volume, Path1_Balance, Path1_AVC_Threshold_Low, Path1_AVC_Threshold_High, Path1_EQ_Band_Select, Path1_EQ_Bass_Adjust, Path1_EQ_Midrange_Adjust, Path1_EQ_Treble_Adjust, Path1_Soft_Clip_Control1, Path1_Soft_Clip_Control2, Path1_Soft_Clip_Threshold_Low, Path1_Soft_Clip_Threshold_High, Path2_Audio_Select_Control, Path2_AVC_Control1, Path2_AVC_Control2, Path2_Mute_Control, Path2_Volume, Path2_Balance, Path2_AVC_Threshold_Low, Path2_AVC_Threshold_High, Path2_EQ_Band_Select, Path2_EQ_Bass_Adjust, Path2_EQ_Midrange_Adjust, Path2_EQ_Treble_Adjust, Path2_Soft_Clip_Control1, Path2_Soft_Clip_Control2, Path2_Soft_Clip_Threshold_Low, Path2_Soft_Clip_Threshold_High, Sample_Rate_Converter_Status1, Sample_Rate_Converter_Status2, Sample_Rate_Converter_Status3, SRC1_Phase_Increment_Low, SRC1_Phase_Increment_Mid, SRC1_Phase_Increment_High, SRC1_FIFO_Read_Threshold, SRC2_Phase_Increment_Low, SRC2_Phase_Increment_Mid, SRC2_Phase_Increment_High, SRC2_FIFO_Read_Threshold, SRC3_Phase_Increment_Low, SRC3_Phase_Increment_Mid, SRC3_Phase_Increment_High, SRC3_FIFO_Read_Threshold, SRC4_Phase_Increment_Low, SRC4_Phase_Increment_Mid, SRC4_Phase_Increment_High, SRC4_FIFO_Read_Threshold, SRC5_Phase_Increment_Low, SRC5_Phase_Increment_Mid, SRC5_Phase_Increment_High, SRC5_FIFO_Read_Threshold, SRC6_Phase_Increment_Low, SRC6_Phase_Increment_Mid, SRC6_Phase_Increment_High, SRC6_FIFO_Read_Threshold, Output_SRC_Source_Select, Baseband_Bypass_Control, Input_SRC_Source_Select1, Input_SRC_Source_Select2, Serial_Audio_Input_Control1, Serial_Audio_Input_Control2, Serial_Audio_Output_Control1, Serial_Audio_Output_Control2, AC97_Shutdown, AC97_Wake_Up, AC97_Reset, AC97_Upsample_Bypass, ACL_Control_0, Space_Holder_Dummy, Space_Holder_Dummy_UNIQ1, Space_Holder_Dummy_UNIQ2, ACL_Control_1, Space_Holder_Dummy_UNIQ3, Space_Holder_Dummy_UNIQ4, Space_Holder_Dummy_UNIQ5, ACL_Control_2, Space_Holder_Dummy_UNIQ6, Space_Holder_Dummy_UNIQ7, Space_Holder_Dummy_UNIQ8, ACL_Control_3, Space_Holder_Dummy_UNIQ9, Space_Holder_Dummy_UNIQ10, Space_Holder_Dummy_UNIQ11, ACL_Command, Space_Holder_Dummy_UNIQ12, Space_Holder_Dummy_UNIQ13, ACL_GPIO_Output_Data, Space_Holder_Dummy_UNIQ14, ACL_GPIO_Input_Data, Space_Holder_Dummy_UNIQ15, ACL_Status_Slot_Interface, Space_Holder_Dummy_UNIQ16, Space_Holder_Dummy_UNIQ17, ACL_Warm_Reset, Space_Holder_Dummy_UNIQ18, Space_Holder_Dummy_UNIQ19, ACL_Tag, Space_Holder_Dummy_UNIQ20, Space_Holder_Dummy_UNIQ21, Space_Holder_Dummy_UNIQ22, RDS_I_Low, RDS_I_High, RDS_Q_Low, number_of_registers } cx25840_register; #endif /* __CX25840_REGISTERS_H */ ivtv-utils-1.4.1/utils/cx25840ctl/cx25840ctl.ggo0000664000076400007640000000036111355717527017440 0ustar andyandypackage "cx25840ctl" version "1.0" purpose "Set and list registers on a CX25840 chip via i2c-dev" option "list-registers" l "dump CX25840 settings to stdout" flag off option "set-registers" s "read CX25840 settings from stdin" flag off ivtv-utils-1.4.1/utils/cx25840ctl/cx25840-registers.c0000664000076400007640000050730611355717527020423 0ustar andyandy/* * cx25840 - register map * * This file is auto generated do not edit. * * There are non obvoius relationships between values. * * Submit errors in this file to the ivtv development mail list. * */ #include #include "cx25840-registers.h" #define DEFINE_REGISTER_INFO_ENTRY(address, type) ((address&0x0fff)|(type<<12)) __u16 cx25840_register_info[] = { DEFINE_REGISTER_INFO_ENTRY(0x0000, RW), DEFINE_REGISTER_INFO_ENTRY(0x0001, RW), DEFINE_REGISTER_INFO_ENTRY(0x0100, RO), DEFINE_REGISTER_INFO_ENTRY(0x0101, RO), DEFINE_REGISTER_INFO_ENTRY(0x0102, RW), DEFINE_REGISTER_INFO_ENTRY(0x0103, RW), DEFINE_REGISTER_INFO_ENTRY(0x0104, RW), DEFINE_REGISTER_INFO_ENTRY(0x0105, RW), DEFINE_REGISTER_INFO_ENTRY(0x0106, RW), DEFINE_REGISTER_INFO_ENTRY(0x0107, RW), DEFINE_REGISTER_INFO_ENTRY(0x0108, RW), DEFINE_REGISTER_INFO_ENTRY(0x0109, RW), DEFINE_REGISTER_INFO_ENTRY(0x010a, RW), DEFINE_REGISTER_INFO_ENTRY(0x010b, RW), DEFINE_REGISTER_INFO_ENTRY(0x010c, RW), DEFINE_REGISTER_INFO_ENTRY(0x010d, RW), DEFINE_REGISTER_INFO_ENTRY(0x010e, RW), DEFINE_REGISTER_INFO_ENTRY(0x010f, RW), DEFINE_REGISTER_INFO_ENTRY(0x0110, RW), DEFINE_REGISTER_INFO_ENTRY(0x0111, RW), DEFINE_REGISTER_INFO_ENTRY(0x0112, RW), DEFINE_REGISTER_INFO_ENTRY(0x0113, RW), DEFINE_REGISTER_INFO_ENTRY(0x0114, RW), DEFINE_REGISTER_INFO_ENTRY(0x0115, RW), DEFINE_REGISTER_INFO_ENTRY(0x0116, RW), DEFINE_REGISTER_INFO_ENTRY(0x0117, RW), DEFINE_REGISTER_INFO_ENTRY(0x0118, RW), DEFINE_REGISTER_INFO_ENTRY(0x0119, RW), DEFINE_REGISTER_INFO_ENTRY(0x011c, RW), DEFINE_REGISTER_INFO_ENTRY(0x011d, RW), DEFINE_REGISTER_INFO_ENTRY(0x011e, RW), DEFINE_REGISTER_INFO_ENTRY(0x011f, RW), DEFINE_REGISTER_INFO_ENTRY(0x0120, RW), DEFINE_REGISTER_INFO_ENTRY(0x0121, RW), DEFINE_REGISTER_INFO_ENTRY(0x0122, RW), DEFINE_REGISTER_INFO_ENTRY(0x0123, RW), DEFINE_REGISTER_INFO_ENTRY(0x0124, RW), DEFINE_REGISTER_INFO_ENTRY(0x0125, RW), DEFINE_REGISTER_INFO_ENTRY(0x0126, RW), DEFINE_REGISTER_INFO_ENTRY(0x0127, RW), DEFINE_REGISTER_INFO_ENTRY(0x0128, RW), DEFINE_REGISTER_INFO_ENTRY(0x0129, RW), DEFINE_REGISTER_INFO_ENTRY(0x012a, RW), DEFINE_REGISTER_INFO_ENTRY(0x012b, RW), DEFINE_REGISTER_INFO_ENTRY(0x012c, RW), DEFINE_REGISTER_INFO_ENTRY(0x012d, RW), DEFINE_REGISTER_INFO_ENTRY(0x012e, RW), DEFINE_REGISTER_INFO_ENTRY(0x012f, RW), DEFINE_REGISTER_INFO_ENTRY(0x0130, RW), DEFINE_REGISTER_INFO_ENTRY(0x0131, RW), DEFINE_REGISTER_INFO_ENTRY(0x0134, RW), DEFINE_REGISTER_INFO_ENTRY(0x0135, RW), DEFINE_REGISTER_INFO_ENTRY(0x0136, RW), DEFINE_REGISTER_INFO_ENTRY(0x013c, RW), DEFINE_REGISTER_INFO_ENTRY(0x013d, RW), DEFINE_REGISTER_INFO_ENTRY(0x013e, RO), DEFINE_REGISTER_INFO_ENTRY(0x013f, RW), DEFINE_REGISTER_INFO_ENTRY(0x0140, RW), DEFINE_REGISTER_INFO_ENTRY(0x0141, RW), DEFINE_REGISTER_INFO_ENTRY(0x0159, RW), DEFINE_REGISTER_INFO_ENTRY(0x015a, RW), DEFINE_REGISTER_INFO_ENTRY(0x015b, RW), DEFINE_REGISTER_INFO_ENTRY(0x015c, RW), DEFINE_REGISTER_INFO_ENTRY(0x015d, RW), DEFINE_REGISTER_INFO_ENTRY(0x015e, RW), DEFINE_REGISTER_INFO_ENTRY(0x015f, RW), DEFINE_REGISTER_INFO_ENTRY(0x0200, RW), DEFINE_REGISTER_INFO_ENTRY(0x0201, RW), DEFINE_REGISTER_INFO_ENTRY(0x0204, RW), DEFINE_REGISTER_INFO_ENTRY(0x0205, RW), DEFINE_REGISTER_INFO_ENTRY(0x0208, RW), DEFINE_REGISTER_INFO_ENTRY(0x0209, RW), DEFINE_REGISTER_INFO_ENTRY(0x020c, RW), DEFINE_REGISTER_INFO_ENTRY(0x0210, RO), DEFINE_REGISTER_INFO_ENTRY(0x0214, RW), DEFINE_REGISTER_INFO_ENTRY(0x0218, RW), DEFINE_REGISTER_INFO_ENTRY(0x0219, RW), DEFINE_REGISTER_INFO_ENTRY(0x023c, RW), DEFINE_REGISTER_INFO_ENTRY(0x023d, RW), DEFINE_REGISTER_INFO_ENTRY(0x023e, RW), DEFINE_REGISTER_INFO_ENTRY(0x0400, RW), DEFINE_REGISTER_INFO_ENTRY(0x0401, RW), DEFINE_REGISTER_INFO_ENTRY(0x0402, RW), DEFINE_REGISTER_INFO_ENTRY(0x0403, RW), DEFINE_REGISTER_INFO_ENTRY(0x0404, RW), DEFINE_REGISTER_INFO_ENTRY(0x0405, RW), DEFINE_REGISTER_INFO_ENTRY(0x0406, RW), DEFINE_REGISTER_INFO_ENTRY(0x0407, RW), DEFINE_REGISTER_INFO_ENTRY(0x0408, RW), DEFINE_REGISTER_INFO_ENTRY(0x0409, RW), DEFINE_REGISTER_INFO_ENTRY(0x040a, RW), DEFINE_REGISTER_INFO_ENTRY(0x040b, RW), DEFINE_REGISTER_INFO_ENTRY(0x040c, RO), DEFINE_REGISTER_INFO_ENTRY(0x040d, RO), DEFINE_REGISTER_INFO_ENTRY(0x040e, RO), DEFINE_REGISTER_INFO_ENTRY(0x0410, RO), DEFINE_REGISTER_INFO_ENTRY(0x0411, RO), DEFINE_REGISTER_INFO_ENTRY(0x0412, RW), DEFINE_REGISTER_INFO_ENTRY(0x0413, RW), DEFINE_REGISTER_INFO_ENTRY(0x0414, RW), DEFINE_REGISTER_INFO_ENTRY(0x0415, RW), DEFINE_REGISTER_INFO_ENTRY(0x0416, RW), DEFINE_REGISTER_INFO_ENTRY(0x0418, RW), DEFINE_REGISTER_INFO_ENTRY(0x0419, RO), DEFINE_REGISTER_INFO_ENTRY(0x041a, RO), DEFINE_REGISTER_INFO_ENTRY(0x041b, RW), DEFINE_REGISTER_INFO_ENTRY(0x041c, RW), DEFINE_REGISTER_INFO_ENTRY(0x041d, RW), DEFINE_REGISTER_INFO_ENTRY(0x041e, RW), DEFINE_REGISTER_INFO_ENTRY(0x041f, RW), DEFINE_REGISTER_INFO_ENTRY(0x0420, RW), DEFINE_REGISTER_INFO_ENTRY(0x0421, RW), DEFINE_REGISTER_INFO_ENTRY(0x0422, RW), DEFINE_REGISTER_INFO_ENTRY(0x0423, RW), DEFINE_REGISTER_INFO_ENTRY(0x0424, RW), DEFINE_REGISTER_INFO_ENTRY(0x0425, RW), DEFINE_REGISTER_INFO_ENTRY(0x0426, RW), DEFINE_REGISTER_INFO_ENTRY(0x0427, RW), DEFINE_REGISTER_INFO_ENTRY(0x0428, RW), DEFINE_REGISTER_INFO_ENTRY(0x0429, RW), DEFINE_REGISTER_INFO_ENTRY(0x042a, RW), DEFINE_REGISTER_INFO_ENTRY(0x042b, RW), DEFINE_REGISTER_INFO_ENTRY(0x042c, RW), DEFINE_REGISTER_INFO_ENTRY(0x042d, RW), DEFINE_REGISTER_INFO_ENTRY(0x042e, RW), DEFINE_REGISTER_INFO_ENTRY(0x042f, RW), DEFINE_REGISTER_INFO_ENTRY(0x0430, RW), DEFINE_REGISTER_INFO_ENTRY(0x0431, RW), DEFINE_REGISTER_INFO_ENTRY(0x0432, RW), DEFINE_REGISTER_INFO_ENTRY(0x0433, RW), DEFINE_REGISTER_INFO_ENTRY(0x0434, RW), DEFINE_REGISTER_INFO_ENTRY(0x0438, RW), DEFINE_REGISTER_INFO_ENTRY(0x0439, RW), DEFINE_REGISTER_INFO_ENTRY(0x043a, RW), DEFINE_REGISTER_INFO_ENTRY(0x043b, RW), DEFINE_REGISTER_INFO_ENTRY(0x043c, RW), DEFINE_REGISTER_INFO_ENTRY(0x043d, RW), DEFINE_REGISTER_INFO_ENTRY(0x043e, RW), DEFINE_REGISTER_INFO_ENTRY(0x043f, RW), DEFINE_REGISTER_INFO_ENTRY(0x0440, RW), DEFINE_REGISTER_INFO_ENTRY(0x0441, RW), DEFINE_REGISTER_INFO_ENTRY(0x0442, RW), DEFINE_REGISTER_INFO_ENTRY(0x0443, RW), DEFINE_REGISTER_INFO_ENTRY(0x0444, RO), DEFINE_REGISTER_INFO_ENTRY(0x0445, RO), DEFINE_REGISTER_INFO_ENTRY(0x0446, RO), DEFINE_REGISTER_INFO_ENTRY(0x0447, RO), DEFINE_REGISTER_INFO_ENTRY(0x0448, RO), DEFINE_REGISTER_INFO_ENTRY(0x0449, RO), DEFINE_REGISTER_INFO_ENTRY(0x044a, RO), DEFINE_REGISTER_INFO_ENTRY(0x044b, RO), DEFINE_REGISTER_INFO_ENTRY(0x044c, RW), DEFINE_REGISTER_INFO_ENTRY(0x044d, RW), DEFINE_REGISTER_INFO_ENTRY(0x044e, RW), DEFINE_REGISTER_INFO_ENTRY(0x044f, RW), DEFINE_REGISTER_INFO_ENTRY(0x0450, RW), DEFINE_REGISTER_INFO_ENTRY(0x0451, RW), DEFINE_REGISTER_INFO_ENTRY(0x0452, RW), DEFINE_REGISTER_INFO_ENTRY(0x0453, RW), DEFINE_REGISTER_INFO_ENTRY(0x0454, RW), DEFINE_REGISTER_INFO_ENTRY(0x0455, RW), DEFINE_REGISTER_INFO_ENTRY(0x0456, RW), DEFINE_REGISTER_INFO_ENTRY(0x0457, RW), DEFINE_REGISTER_INFO_ENTRY(0x0458, RW), DEFINE_REGISTER_INFO_ENTRY(0x0459, RW), DEFINE_REGISTER_INFO_ENTRY(0x045a, RW), DEFINE_REGISTER_INFO_ENTRY(0x045b, RW), DEFINE_REGISTER_INFO_ENTRY(0x045c, RW), DEFINE_REGISTER_INFO_ENTRY(0x045d, RW), DEFINE_REGISTER_INFO_ENTRY(0x045e, RW), DEFINE_REGISTER_INFO_ENTRY(0x045f, RW), DEFINE_REGISTER_INFO_ENTRY(0x0460, RW), DEFINE_REGISTER_INFO_ENTRY(0x0461, RW), DEFINE_REGISTER_INFO_ENTRY(0x0462, RW), DEFINE_REGISTER_INFO_ENTRY(0x0463, RW), DEFINE_REGISTER_INFO_ENTRY(0x0464, RW), DEFINE_REGISTER_INFO_ENTRY(0x0465, RW), DEFINE_REGISTER_INFO_ENTRY(0x0466, RW), DEFINE_REGISTER_INFO_ENTRY(0x0467, RW), DEFINE_REGISTER_INFO_ENTRY(0x0468, RW), DEFINE_REGISTER_INFO_ENTRY(0x0469, RW), DEFINE_REGISTER_INFO_ENTRY(0x046a, RW), DEFINE_REGISTER_INFO_ENTRY(0x046b, RW), DEFINE_REGISTER_INFO_ENTRY(0x046c, RW), DEFINE_REGISTER_INFO_ENTRY(0x046d, RW), DEFINE_REGISTER_INFO_ENTRY(0x046e, RW), DEFINE_REGISTER_INFO_ENTRY(0x046f, RW), DEFINE_REGISTER_INFO_ENTRY(0x0470, RW), DEFINE_REGISTER_INFO_ENTRY(0x0471, RW), DEFINE_REGISTER_INFO_ENTRY(0x0472, RW), DEFINE_REGISTER_INFO_ENTRY(0x0473, RW), DEFINE_REGISTER_INFO_ENTRY(0x0474, RW), DEFINE_REGISTER_INFO_ENTRY(0x0475, RW), DEFINE_REGISTER_INFO_ENTRY(0x0476, RW), DEFINE_REGISTER_INFO_ENTRY(0x0477, RW), DEFINE_REGISTER_INFO_ENTRY(0x0478, RW), DEFINE_REGISTER_INFO_ENTRY(0x0479, RW), DEFINE_REGISTER_INFO_ENTRY(0x047a, RW), DEFINE_REGISTER_INFO_ENTRY(0x047b, RW), DEFINE_REGISTER_INFO_ENTRY(0x047c, RW), DEFINE_REGISTER_INFO_ENTRY(0x047d, RW), DEFINE_REGISTER_INFO_ENTRY(0x047e, RW), DEFINE_REGISTER_INFO_ENTRY(0x047f, RW), DEFINE_REGISTER_INFO_ENTRY(0x0480, RW), DEFINE_REGISTER_INFO_ENTRY(0x0481, RW), DEFINE_REGISTER_INFO_ENTRY(0x0484, RW), DEFINE_REGISTER_INFO_ENTRY(0x0485, RW), DEFINE_REGISTER_INFO_ENTRY(0x0487, RW), DEFINE_REGISTER_INFO_ENTRY(0x0488, RW), DEFINE_REGISTER_INFO_ENTRY(0x0489, RW), DEFINE_REGISTER_INFO_ENTRY(0x048a, RW), DEFINE_REGISTER_INFO_ENTRY(0x048b, RW), DEFINE_REGISTER_INFO_ENTRY(0x048c, RW), DEFINE_REGISTER_INFO_ENTRY(0x048d, RW), DEFINE_REGISTER_INFO_ENTRY(0x048e, RW), DEFINE_REGISTER_INFO_ENTRY(0x0490, RW), DEFINE_REGISTER_INFO_ENTRY(0x0491, RW), DEFINE_REGISTER_INFO_ENTRY(0x0492, RW), DEFINE_REGISTER_INFO_ENTRY(0x0493, RW), DEFINE_REGISTER_INFO_ENTRY(0x0494, RW), DEFINE_REGISTER_INFO_ENTRY(0x0495, RW), DEFINE_REGISTER_INFO_ENTRY(0x0496, RW), DEFINE_REGISTER_INFO_ENTRY(0x0497, RW), DEFINE_REGISTER_INFO_ENTRY(0x0498, RW), DEFINE_REGISTER_INFO_ENTRY(0x049c, RW), DEFINE_REGISTER_INFO_ENTRY(0x049d, RW), DEFINE_REGISTER_INFO_ENTRY(0x049e, RW), DEFINE_REGISTER_INFO_ENTRY(0x049f, RW), DEFINE_REGISTER_INFO_ENTRY(0x04a0, RW), DEFINE_REGISTER_INFO_ENTRY(0x04a1, RW), DEFINE_REGISTER_INFO_ENTRY(0x04a2, RW), DEFINE_REGISTER_INFO_ENTRY(0x04a4, RW), DEFINE_REGISTER_INFO_ENTRY(0x04a5, RW), DEFINE_REGISTER_INFO_ENTRY(0x04b4, RO), DEFINE_REGISTER_INFO_ENTRY(0x04b8, RW), DEFINE_REGISTER_INFO_ENTRY(0x0800, RW), DEFINE_REGISTER_INFO_ENTRY(0x0801, RW), DEFINE_REGISTER_INFO_ENTRY(0x0802, RW), DEFINE_REGISTER_INFO_ENTRY(0x0803, RW), DEFINE_REGISTER_INFO_ENTRY(0x0804, RO), DEFINE_REGISTER_INFO_ENTRY(0x0805, RO), DEFINE_REGISTER_INFO_ENTRY(0x0808, RW), DEFINE_REGISTER_INFO_ENTRY(0x0809, RW), DEFINE_REGISTER_INFO_ENTRY(0x080a, RO), DEFINE_REGISTER_INFO_ENTRY(0x080b, RW), DEFINE_REGISTER_INFO_ENTRY(0x0810, RW), DEFINE_REGISTER_INFO_ENTRY(0x0812, RW), DEFINE_REGISTER_INFO_ENTRY(0x0813, RW), DEFINE_REGISTER_INFO_ENTRY(0x0814, RW), DEFINE_REGISTER_INFO_ENTRY(0x0815, RW), DEFINE_REGISTER_INFO_ENTRY(0x0816, RW), DEFINE_REGISTER_INFO_ENTRY(0x0817, RW), DEFINE_REGISTER_INFO_ENTRY(0x081b, RW), DEFINE_REGISTER_INFO_ENTRY(0x08cc, RW), DEFINE_REGISTER_INFO_ENTRY(0x08cd, RW), DEFINE_REGISTER_INFO_ENTRY(0x08ce, RW), DEFINE_REGISTER_INFO_ENTRY(0x08cf, RW), DEFINE_REGISTER_INFO_ENTRY(0x08d0, RW), DEFINE_REGISTER_INFO_ENTRY(0x08d1, RW), DEFINE_REGISTER_INFO_ENTRY(0x08d2, RW), DEFINE_REGISTER_INFO_ENTRY(0x08d3, RW), DEFINE_REGISTER_INFO_ENTRY(0x08d4, RW), DEFINE_REGISTER_INFO_ENTRY(0x08d5, RW), DEFINE_REGISTER_INFO_ENTRY(0x08d6, RW), DEFINE_REGISTER_INFO_ENTRY(0x08d7, RW), DEFINE_REGISTER_INFO_ENTRY(0x08d8, RW), DEFINE_REGISTER_INFO_ENTRY(0x08d9, RW), DEFINE_REGISTER_INFO_ENTRY(0x08da, RW), DEFINE_REGISTER_INFO_ENTRY(0x08db, RW), DEFINE_REGISTER_INFO_ENTRY(0x08dc, RW), DEFINE_REGISTER_INFO_ENTRY(0x08dd, RW), DEFINE_REGISTER_INFO_ENTRY(0x08de, RW), DEFINE_REGISTER_INFO_ENTRY(0x08df, RW), DEFINE_REGISTER_INFO_ENTRY(0x08e0, RW), DEFINE_REGISTER_INFO_ENTRY(0x08e1, RW), DEFINE_REGISTER_INFO_ENTRY(0x08e2, RW), DEFINE_REGISTER_INFO_ENTRY(0x08e3, RW), DEFINE_REGISTER_INFO_ENTRY(0x08e4, RW), DEFINE_REGISTER_INFO_ENTRY(0x08e5, RW), DEFINE_REGISTER_INFO_ENTRY(0x08e6, RW), DEFINE_REGISTER_INFO_ENTRY(0x08e7, RW), DEFINE_REGISTER_INFO_ENTRY(0x08e8, RW), DEFINE_REGISTER_INFO_ENTRY(0x08e9, RW), DEFINE_REGISTER_INFO_ENTRY(0x08ea, RW), DEFINE_REGISTER_INFO_ENTRY(0x08eb, RW), DEFINE_REGISTER_INFO_ENTRY(0x08ec, RW), DEFINE_REGISTER_INFO_ENTRY(0x08ed, RW), DEFINE_REGISTER_INFO_ENTRY(0x08ee, RW), DEFINE_REGISTER_INFO_ENTRY(0x08ef, RW), DEFINE_REGISTER_INFO_ENTRY(0x08f1, RW), DEFINE_REGISTER_INFO_ENTRY(0x08f2, RW), DEFINE_REGISTER_INFO_ENTRY(0x08f3, RO), DEFINE_REGISTER_INFO_ENTRY(0x08f8, RW), DEFINE_REGISTER_INFO_ENTRY(0x08f9, RW), DEFINE_REGISTER_INFO_ENTRY(0x08fa, RW), DEFINE_REGISTER_INFO_ENTRY(0x08fb, RW), DEFINE_REGISTER_INFO_ENTRY(0x08fc, RW), DEFINE_REGISTER_INFO_ENTRY(0x08fd, RW), DEFINE_REGISTER_INFO_ENTRY(0x08fe, RW), DEFINE_REGISTER_INFO_ENTRY(0x08ff, RW), DEFINE_REGISTER_INFO_ENTRY(0x0900, RW), DEFINE_REGISTER_INFO_ENTRY(0x0901, RW), DEFINE_REGISTER_INFO_ENTRY(0x0902, RW), DEFINE_REGISTER_INFO_ENTRY(0x0903, RW), DEFINE_REGISTER_INFO_ENTRY(0x0904, RW), DEFINE_REGISTER_INFO_ENTRY(0x0905, RW), DEFINE_REGISTER_INFO_ENTRY(0x0906, RW), DEFINE_REGISTER_INFO_ENTRY(0x0907, RW), DEFINE_REGISTER_INFO_ENTRY(0x0908, RW), DEFINE_REGISTER_INFO_ENTRY(0x0909, RW), DEFINE_REGISTER_INFO_ENTRY(0x090a, RW), DEFINE_REGISTER_INFO_ENTRY(0x090b, RW), DEFINE_REGISTER_INFO_ENTRY(0x090c, RW), DEFINE_REGISTER_INFO_ENTRY(0x090d, RW), DEFINE_REGISTER_INFO_ENTRY(0x090e, RW), DEFINE_REGISTER_INFO_ENTRY(0x090f, RW), DEFINE_REGISTER_INFO_ENTRY(0x0910, RW), DEFINE_REGISTER_INFO_ENTRY(0x0911, RW), DEFINE_REGISTER_INFO_ENTRY(0x0912, RW), DEFINE_REGISTER_INFO_ENTRY(0x0913, RW), DEFINE_REGISTER_INFO_ENTRY(0x0914, RW), DEFINE_REGISTER_INFO_ENTRY(0x0915, RW), DEFINE_REGISTER_INFO_ENTRY(0x0918, RW), DEFINE_REGISTER_INFO_ENTRY(0x0919, RW), DEFINE_REGISTER_INFO_ENTRY(0x091c, RW), DEFINE_REGISTER_INFO_ENTRY(0x091d, RW), DEFINE_REGISTER_INFO_ENTRY(0x091e, RW), DEFINE_REGISTER_INFO_ENTRY(0x091f, RW), DEFINE_REGISTER_INFO_ENTRY(0x0980, RW), DEFINE_REGISTER_INFO_ENTRY(0x0981, RW), DEFINE_REGISTER_INFO_ENTRY(0x0982, RW), DEFINE_REGISTER_INFO_ENTRY(0x0983, RW), DEFINE_REGISTER_INFO_ENTRY(0x0984, RW), DEFINE_REGISTER_INFO_ENTRY(0x0985, RW), DEFINE_REGISTER_INFO_ENTRY(0x0986, RW), DEFINE_REGISTER_INFO_ENTRY(0x0987, RW), DEFINE_REGISTER_INFO_ENTRY(0x0988, RW), DEFINE_REGISTER_INFO_ENTRY(0x0989, RW), DEFINE_REGISTER_INFO_ENTRY(0x098a, RW), DEFINE_REGISTER_INFO_ENTRY(0x098b, RW), DEFINE_REGISTER_INFO_ENTRY(0x098c, RW), DEFINE_REGISTER_INFO_ENTRY(0x098d, RW), DEFINE_REGISTER_INFO_ENTRY(0x098e, RW), DEFINE_REGISTER_INFO_ENTRY(0x098f, RW), DEFINE_REGISTER_INFO_ENTRY(0x0990, RW), DEFINE_REGISTER_INFO_ENTRY(0x0991, RW), DEFINE_REGISTER_INFO_ENTRY(0x0992, RW), DEFINE_REGISTER_INFO_ENTRY(0x0994, RW), DEFINE_REGISTER_INFO_ENTRY(0x0995, RW), DEFINE_REGISTER_INFO_ENTRY(0x0998, RW), DEFINE_REGISTER_INFO_ENTRY(0x0999, RW), DEFINE_REGISTER_INFO_ENTRY(0x099c, RW), DEFINE_REGISTER_INFO_ENTRY(0x099d, RW), DEFINE_REGISTER_INFO_ENTRY(0x099e, RW), DEFINE_REGISTER_INFO_ENTRY(0x09a0, RW), DEFINE_REGISTER_INFO_ENTRY(0x09a1, RW), DEFINE_REGISTER_INFO_ENTRY(0x09a2, RW), DEFINE_REGISTER_INFO_ENTRY(0x09a4, RO), DEFINE_REGISTER_INFO_ENTRY(0x09a5, RO), DEFINE_REGISTER_INFO_ENTRY(0x09a6, RO), DEFINE_REGISTER_INFO_ENTRY(0x09a7, RO), DEFINE_REGISTER_INFO_ENTRY(0x09c0, RO), DEFINE_REGISTER_INFO_ENTRY(0x09c1, RO), DEFINE_REGISTER_INFO_ENTRY(0x09c2, RO) }; char *cx25840_register_name[] = { "Host_Register_1", "Host_Register_2", "Device_ID_Low_Byte", "Device_ID_High_Byte", "Configuration", "Video_Input_Control", "AFE_Control_1", "AFE_Control_2", "AFE_Control_3", "AFE_Control_4", "Video_PLL_Integer", "Video_PLL_Divider", "Aux_PLL_Integer", "Aux_PLL_Divider", "Video_PLL_Fractional_1", "Video_PLL_Fractional_2", "Video_PLL_Fractional_3", "Video_PLL_Fractional_4", "Aux_PLL_Fractional_1", "Aux_PLL_Fractional_2", "Aux_PLL_Fractional_3", "Aux_PLL_Fractional_4", "Pin_Control_1", "Pin_Control_2", "Pin_Control_3", "Pin_Control_4", "Pin_Control_5", "Pin_Control_6", "Pin_Configuration_1", "Pin_Configuration_2", "Pin_Configuration_3", "Pin_Configuration_4", "Pin_Configuration_5", "Pin_Configuration_6", "Pin_Configuration_7", "Pin_Configuration_8", "Pin_Configuration_9", "Pin_Configuration_10", "Pin_Configuration_11", "Pin_Configuration_12", "Video_Count_Low", "Video_Count_Mid", "Video_Count_High", "Audio_Lock", "Audio_Count_Low", "Audio_Count_Mid", "Audio_Lock_2", "Audio_Lock_3", "Power_Control_1", "Power_Control_2", "AFE_Diagnostic_Control_1", "AFE_Diagnostic_Control_2", "AFE_Diagnostic_Control_3", "AFE_Diagnostic_Control_5", "AFE_Diagnostic_Control_6", "AFE_Diagnostic_Control_7", "AFE_Diagnostic_Control_8", "PLL_Diagnostic_Control_1", "PLL_Diagnostic_Control_2", "DLL1_Diagnostic_Control_2", "DLL1_Diagnostic_Control_3", "DLL1_Diagnostic_Control_4", "DLL2_Diagnostic_Control_1", "DLL2_Diagnostic_Control_2", "DLL2_Diagnostic_Control_3", "DLL2_Diagnostic_Control_4", "IR_Control_1", "IR_Control_2", "IR_TX_Clock_Divider_Low", "IR_TX_Clock_Divider_High", "IR_RX_Clock_Divider_Low", "IR_RX_Clock_Divider_High", "IR_TX_Carrier_Duty_Cycle", "IR_Status", "IR_Interrupt_Enable", "IR_Low_Pass_Filter_Low", "IR_Low_Pass_Filter_High", "IR_FIFO_Low", "IR_FIFO_High", "IR_FIFO_Level", "Video_Mode_Control_1", "Video_Mode_Control_2", "Video_Mode_Control_3", "Video_Mode_Control_4", "Video_Out_Control_1", "Video_Out_Control_2", "Video_Out_Control_3", "Video_Out_Control_4", "Ancillary_IDID_0", "Ancillary_IDID_1", "Ancillary_IDID_0_1", "Ancillary_Audio_Output_Control", "Copy_Protection_Status", "General_Status_1", "General_Status_2", "Interrupt_Status_1", "Interrupt_Status_2", "Interrupt_Mask_1", "Interrupt_Mask_2", "Brightness", "Contrast", "Luma_Control", "Horizontal_Scaling_Low", "Horizontal_Scaling_Mid", "Horizontal_Scaling_High", "Horizontal_Scaling_Control", "Vertical_Scaling_Low", "Vertical_Scaling_High", "Vertical_Scaling_Control", "Vertical_Line_Control", "Saturation_U", "Saturation_V", "Hue", "Chroma_Control", "VBI_Line_Control_1", "VBI_Line_Control_2", "VBI_Line_Control_3", "VBI_Line_Control_4", "VBI_Line_Control_5", "VBI_Line_Control_6", "VBI_Line_Control_7", "VBI_Line_Control_8", "VBI_Line_Control_9", "VBI_Line_Control_10", "VBI_Line_Control_11", "VBI_Line_Control_12", "VBI_Line_Control_13", "VBI_Line_Control_14", "VBI_Line_Control_15", "VBI_Line_Control_16", "VBI_Line_Control_17", "VBI_Frame_Code_Search_Mode", "VBI_Alternate_Frame_Code_Type", "VBI_Alternate_1_Frame_Code", "VBI_Alternate_2_Frame_Code", "VBI_Miscellaneous_Config_1", "TTX_Packet_Address_1", "TTX_Packet_Address_2", "TTX_Packet_Address_3", "VBI_1_and_2_SDID", "VBI_3_SDID", "VBI_FIFO_Reset", "VBI_Hamming", "Closed_Caption_Status", "Closed_Caption_Data", "GEMSTAR_1x_Status", "GEMSTAR_1x_Data", "GEMSTAR_2x_Status", "GEMSTAR_2x_Data", "WSS_Status", "WSS_Data", "VBI_Custom_1_Horizontal_Delay", "VBI_Custom_1_Bit_Increment", "VBI_Custom_1_Slice_Distance", "VBI_Custom_1_Clock_Run_in_Window", "VBI_Custom_1_Frame_Code_Low", "VBI_Custom_1_Frame_Code_Mid", "VBI_Custom_1_Frame_Code_High", "VBI_Custom_1_Frame_Code_Length", "VBI_Custom_1_Clock_Run_in_Period", "VBI_Custom_1_Clock_Run_in_Margin_and_Length", "VBI_Custom_1_Payload_Length", "VBI_Custom_1_Miscellaneous", "VBI_Custom_2_Horizontal_Delay", "VBI_Custom_2_Bit_Increment", "VBI_Custom_2_Slice_Distance", "VBI_Custom_2_Clock_Run_In_Window", "VBI_Custom_2_Frame_Code_Low", "VBI_Custom_2_Frame_Code_Mid", "VBI_Custom_2_Frame_Code_High", "VBI_Custom_2_Frame_Code_Length", "VBI_Custom_2_Clock_Run_in_Period", "VBI_Custom_2_Clock_Run_in_Margin_and_Length", "VBI_Custom_2_Payload_Length", "VBI_Custom_2_Miscellaneous", "VBI_Custom_3_Horizontal_Delay", "VBI_Custom_3_Bit_Increment", "VBI_Custom_3_Slice_Distance", "VBI_Custom_3_Clock_Run_in_Window", "VBI_Custom_3_Frame_Code_Low", "VBI_Custom_3_Frame_Code_Mid", "VBI_Custom_3_Frame_Code_High", "VBI_Custom_3_Frame_Code_Length", "VBI_Custom_3_Clock_Run_in_Period", "VBI_Custom_3_Clock_Run_in_Margin_and_Length", "VBI_Custom_3_Payload_Length", "VBI_Custom_3_Miscellaneous", "Horizontal_Blanking_Delay_Low", "Horizontal_Blanking_Delay_High", "Horizontal_Active_High", "Burst_Gate_Delay", "Vertical_Blanking_Delay_Low", "Vertical_Blanking_Delay_High", "Vertical_Active_High", "Vertical_Blanking_Delay_656", "SRC_Decimation_Ratio_Low", "SRC_Decimation_Ratio_High", "Comb_Filter_Bandwidth_Select", "Comb_Filter_Enable", "Subcarrier_Step_Size_Low", "Subcarrier_Step_Size_Mid", "Subcarrier_Step_Size_High", "VBI_Offset", "Field_Count_Low", "Field_Count_High", "Temporal_Decimation", "Miscellaneous_Timing_Control", "Video_Detect_Configuration", "VGA_Gain_Control", "AGC_Gain_Control_Low", "AGC_Gain_Control_High", "Digital_Front_End_Control", "VGA_Sync_Control", "VGA_Track_Range", "VGA_Acquire_Range", "DFE_Control", "Backporch_Loop_Gain", "DFT_Threshold", "Backporch_Percent", "PLL_Offset_Low", "PLL_Offset_High", "PLL_Indirect_Loop_Gain", "PLL_Direct_Loop_Gain", "Horizontal_Tracking_Loop_Indirect_Gain", "Luma_Comb_Error_Limit_Max", "Luma_Comb_Threshold", "Chroma_Comb_Error_Limit_Max", "Comb_Phase_Limit_Max", "White_Crush_Increment", "White_Crush_Decrement", "White_Crush_Comparison_Point", "Soft_Reset_Mask_1", "Soft_Reset_Mask_2", "Version_ID", "Miscellaneous_Diagnostic_Control", "Download_Address_Low_Byte", "Download_Address_High_Byte", "Download_Data_Control", "Download_Control", "Mode_Detect_Status_0", "Mode_Detect_Status_1", "Audio_Configuration", "Preferred_Decode_Mode", "Embedded_Microcontroller_Video_Format", "Audio_Format_Control_0", "Soft_Reset", "Audio_Interrupt_Control", "Audio_Interrupt_Status", "Analog_AGC_Hysteresis1", "Analog_AGC_Hysteresis2", "Analog_AGC_Control", "AFE_12DB_ENABLE", "IF_SRC_Mode", "Phase_Fix_Control", "Dematrix_Bypass", "Dematrix_Select_Control", "Digital_Audio_Input_Shifter", "Path1_Audio_Select_Control", "Path1_AVC_Control1", "Path1_AVC_Control2", "Mute_Control", "Path1_Volume", "Path1_Balance", "Path1_AVC_Threshold_Low", "Path1_AVC_Threshold_High", "Path1_EQ_Band_Select", "Path1_EQ_Bass_Adjust", "Path1_EQ_Midrange_Adjust", "Path1_EQ_Treble_Adjust", "Path1_Soft_Clip_Control1", "Path1_Soft_Clip_Control2", "Path1_Soft_Clip_Threshold_Low", "Path1_Soft_Clip_Threshold_High", "Path2_Audio_Select_Control", "Path2_AVC_Control1", "Path2_AVC_Control2", "Path2_Mute_Control", "Path2_Volume", "Path2_Balance", "Path2_AVC_Threshold_Low", "Path2_AVC_Threshold_High", "Path2_EQ_Band_Select", "Path2_EQ_Bass_Adjust", "Path2_EQ_Midrange_Adjust", "Path2_EQ_Treble_Adjust", "Path2_Soft_Clip_Control1", "Path2_Soft_Clip_Control2", "Path2_Soft_Clip_Threshold_Low", "Path2_Soft_Clip_Threshold_High", "Sample_Rate_Converter_Status1", "Sample_Rate_Converter_Status2", "Sample_Rate_Converter_Status3", "SRC1_Phase_Increment_Low", "SRC1_Phase_Increment_Mid", "SRC1_Phase_Increment_High", "SRC1_FIFO_Read_Threshold", "SRC2_Phase_Increment_Low", "SRC2_Phase_Increment_Mid", "SRC2_Phase_Increment_High", "SRC2_FIFO_Read_Threshold", "SRC3_Phase_Increment_Low", "SRC3_Phase_Increment_Mid", "SRC3_Phase_Increment_High", "SRC3_FIFO_Read_Threshold", "SRC4_Phase_Increment_Low", "SRC4_Phase_Increment_Mid", "SRC4_Phase_Increment_High", "SRC4_FIFO_Read_Threshold", "SRC5_Phase_Increment_Low", "SRC5_Phase_Increment_Mid", "SRC5_Phase_Increment_High", "SRC5_FIFO_Read_Threshold", "SRC6_Phase_Increment_Low", "SRC6_Phase_Increment_Mid", "SRC6_Phase_Increment_High", "SRC6_FIFO_Read_Threshold", "Output_SRC_Source_Select", "Baseband_Bypass_Control", "Input_SRC_Source_Select1", "Input_SRC_Source_Select2", "Serial_Audio_Input_Control1", "Serial_Audio_Input_Control2", "Serial_Audio_Output_Control1", "Serial_Audio_Output_Control2", "AC97_Shutdown", "AC97_Wake_Up", "AC97_Reset", "AC97_Upsample_Bypass", "ACL_Control_0", "Space_Holder_Dummy", "Space_Holder_Dummy_UNIQ1", "Space_Holder_Dummy_UNIQ2", "ACL_Control_1", "Space_Holder_Dummy_UNIQ3", "Space_Holder_Dummy_UNIQ4", "Space_Holder_Dummy_UNIQ5", "ACL_Control_2", "Space_Holder_Dummy_UNIQ6", "Space_Holder_Dummy_UNIQ7", "Space_Holder_Dummy_UNIQ8", "ACL_Control_3", "Space_Holder_Dummy_UNIQ9", "Space_Holder_Dummy_UNIQ10", "Space_Holder_Dummy_UNIQ11", "ACL_Command", "Space_Holder_Dummy_UNIQ12", "Space_Holder_Dummy_UNIQ13", "ACL_GPIO_Output_Data", "Space_Holder_Dummy_UNIQ14", "ACL_GPIO_Input_Data", "Space_Holder_Dummy_UNIQ15", "ACL_Status_Slot_Interface", "Space_Holder_Dummy_UNIQ16", "Space_Holder_Dummy_UNIQ17", "ACL_Warm_Reset", "Space_Holder_Dummy_UNIQ18", "Space_Holder_Dummy_UNIQ19", "ACL_Tag", "Space_Holder_Dummy_UNIQ20", "Space_Holder_Dummy_UNIQ21", "Space_Holder_Dummy_UNIQ22", "RDS_I_Low", "RDS_I_High", "RDS_Q_Low" }; __u8 cx25840_register_default[] = { 0x04, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0xdc, 0x04, 0x00, 0x0f, 0x04, 0x0a, 0x10, 0xfe, 0xe2, 0x2b, 0x00, 0x09, 0xd7, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x89, 0x38, 0x00, 0x00, 0xf8, 0x93, 0x11, 0xa0, 0xff, 0x5f, 0x00, 0x11, 0x00, 0x00, 0x02, 0x18, 0x05, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x21, 0xe3, 0x00, 0x00, 0x21, 0xe3, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x08, 0x00, 0x31, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0x07, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x70, 0xff, 0x29, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x99, 0x10, 0x2c, 0x01, 0x00, 0x00, 0x03, 0x0d, 0xc4, 0x08, 0x06, 0x77, 0x88, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x02, 0x14, 0x0a, 0x14, 0x6e, 0xca, 0x36, 0x06, 0xe7, 0x00, 0x00, 0x08, 0x20, 0xf6, 0x84, 0x02, 0x7a, 0x00, 0x00, 0x5b, 0x14, 0xe0, 0x1e, 0x20, 0x1f, 0x02, 0x50, 0x66, 0x1f, 0x7c, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x01, 0xf8, 0xdc, 0x40, 0x10, 0x8a, 0x02, 0x3f, 0xcd, 0x00, 0x03, 0x1f, 0x16, 0x22, 0x14, 0x00, 0x50, 0x20, 0x0f, 0x00, 0x0c, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x05, 0x09, 0x0e, 0x20, 0x00, 0x09, 0x00, 0x00, 0x00, 0x90, 0x98, 0x08, 0x01, 0x24, 0x00, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x09, 0x99, 0xff, 0x7f, 0x90, 0x98, 0x08, 0x01, 0x24, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x09, 0x99, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x7c, 0x86, 0x01, 0x08, 0x7c, 0x86, 0x01, 0x08, 0xaa, 0x4f, 0x01, 0x08, 0xaa, 0x4f, 0x01, 0x08, 0x53, 0x04, 0x01, 0x08, 0xaa, 0x4f, 0x01, 0x08, 0xc9, 0x00, 0xb0, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; value_map SLEEP_value_map[] = { {0x0000, "Do not power down"}, {0x0001, "Power down"}, {0, 0} }; value_map DIGITAL_PWR_DN_value_map[] = { {0x0000, "Do not gate"}, {0x0001, "Hold clocks in high state"}, {0, 0} }; value_map REF_CLK_SEL_value_map[] = { {0x0000, "Single-ended input on XTI pin"}, {0x0001, "Differential signal required on crystal pins"}, {0, 0} }; value_map PWR_DN_VID_PLL_value_map[] = { {0x0000, "Do not power down"}, {0x0001, "Power down"}, {0, 0} }; value_map PWR_DN_AUX_PLL_value_map[] = { {0x0000, "Do not power down"}, {0x0001, "Power down"}, {0, 0} }; value_map AUTO_INC_DIS_value_map[] = { {0x0000, "Do the auto-address increment"}, {0x0001, "Do not increment the address"}, {0, 0} }; value_map SLV_SI_DIS_value_map[] = { {0x0000, "Glitch filters and slew rate control enabled"}, {0, 0} }; value_map FORCE_CHIP_SEL_VIPCLK_value_map[] = { {0x0000, "Use the CHIP_SEL/VIPCLK pin for I2C decode"}, {0x0001, "The I2C chip select signal is forced to a 1 regardless of the"}, {0, 0} }; value_map PREFETCH_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map DEVICE_ID_value_map[] = { {0x8400, "CX25840-21"}, {0x8401, "CX25840-22"}, {0x8403, "CX25840-23"}, {0x8404, "CX25840-24"}, {0x8410, "CX25841-21"}, {0x8411, "CX25841-22"}, {0x8413, "CX25841-23"}, {0x8414, "CX25841-24"}, {0x8420, "CX25842-21"}, {0x8421, "CX25842-22"}, {0x8423, "CX25842-23"}, {0x8424, "CX25842-24"}, {0x8430, "CX25843-21"}, {0x8431, "CX25843-22"}, {0x8433, "CX25843-23"}, {0x8434, "CX25843-24"}, {0, 0} }; value_map SOFT_RST_value_map[] = { {0x0000, "Deassert reset"}, {0x0001, "Assert reset"}, {0, 0} }; value_map CH_SEL_ADC2_value_map[] = { {0x0000, "Analog input CH{2}"}, {0x0001, "Analog input CH{3}"}, {0, 0} }; value_map DUAL_MODE_ADC2_value_map[] = { {0x0000, "Normal mode"}, {0x0001, "Dual sampling mode"}, {0, 0} }; value_map CHIP_ACFG_DIS_value_map[] = { {0x0000, "Allow VID_PLL_INT, VID_PLL_FRAC, and AFE control"}, {0x0001, "Disable autoconfig"}, {0, 0} }; value_map CH_1__SOURCE_value_map[] = { {0x0000, "CVBS1/Y1"}, {0x0001, "CVBS2/Y2"}, {0x0002, "CVBS3/Y3"}, {0x0003, "CVBS4/Y4/Pb1"}, {0x0004, "CVBS5/C1/Pb2"}, {0x0005, "CVBS6/C2"}, {0x0006, "CVBS7/C3/Pr1"}, {0x0007, "CVBS8/C4/Pr2"}, {0, 0} }; value_map CH_2__SOURCE_value_map[] = { {0x0000, "CVBS4/Y4/Pb1"}, {0x0001, "CVBS5/C1/Pb2"}, {0x0002, "CVBS6/C2"}, {0x0003, "None"}, {0, 0} }; value_map CH_3__SOURCE_value_map[] = { {0x0000, "CVBS7/C3/Pr1"}, {0x0001, "CVBS8/C4/Pr2"}, {0x0002, "None"}, {0x0003, "None"}, {0, 0} }; value_map EN_12DB_CH1_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map EN_12DB_CH2_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map EN_12DB_CH3_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map VGA_SEL_CH1_value_map[] = { {0x0000, "Video decoder drives VGA gain setting"}, {0x0001, "Audio decoder drives VGA gain setting"}, {0, 0} }; value_map VGA_SEL_CH2_value_map[] = { {0x0000, "Video decoder drives VGA gain setting"}, {0x0001, "Audio decoder drives VGA gain setting"}, {0, 0} }; value_map VGA_SEL_CH3_value_map[] = { {0x0000, "Video decoder drives VGA gain setting"}, {0x0001, "Audio decoder drives VGA gain setting"}, {0, 0} }; value_map CLAMP_SEL_CH1_value_map[] = { {0x0000, "Video decoder drives clamp level"}, {0x0001, "Clamp level is fixed at 3'b111 (midcode clamp). Use for"}, {0, 0} }; value_map CLAMP_SEL_CH2_value_map[] = { {0x0000, "Video decoder drives clamp level"}, {0x0001, "Clamp level is fixed at 3'b111 (midcode clamp). Use for"}, {0, 0} }; value_map CLAMP_SEL_CH3_value_map[] = { {0x0000, "Video decoder drives clamp level"}, {0x0001, "Clamp level is fixed at 3'b111 (midcode clamp). Use for"}, {0, 0} }; value_map CHROMA_IN_SEL_value_map[] = { {0x0000, "ADC 1"}, {0x0001, "ADC 2"}, {0, 0} }; value_map LUMA_IN_SEL_value_map[] = { {0x0000, "ADC 1"}, {0x0001, "ADC 2"}, {0, 0} }; value_map AUD_IN_SEL_value_map[] = { {0x0000, "ADC1 input"}, {0x0001, "Miscellaneous Chip Control input"}, {0, 0} }; value_map CLAMP_EN_CH1_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable (power-up)"}, {0, 0} }; value_map CLAMP_EN_CH2_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map CLAMP_EN_CH3_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map GPIO0_OUT_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map GPIO1_OUT_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map CHIP_SEL_VIPCLK_OUT_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map IRQN_OUT_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map IR_RX_OUT_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map IR_TX_OUT_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map DVALID_OUT_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map FIELD_OUT_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map HRESET_OUT_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map VRESET_OUT_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map VID_OUT_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map PIXCLK_OUT_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map SA_SDIN_OUT_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map SA_BCLKIN_OUT_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map SA_WCLKIN_OUT_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map SA_SDOUT_OUT_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map SA_BCLKOUT_OUT_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map SA_WCLKOUT_OUT_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map PLL_CLK_OUT_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map AC_OUT_OUT_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map AC_IN_OUT_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map IRQ_N_PRGM4_value_map[] = { {0x0000, "IRQ_N/PRGM4 is active low"}, {0x0001, "IRQ_N/PRGM4 is active high"}, {0, 0} }; value_map VID_IRQ_STAT_value_map[] = { {0x0000, "Interrupt is not active"}, {0x0001, "Interrupt is active"}, {0, 0} }; value_map IR_IRQ_STAT_value_map[] = { {0x0000, "Interrupt is not active"}, {0x0001, "Interrupt is active"}, {0, 0} }; value_map VID_OUT_SPD_value_map[] = { {0x0000, "Medium"}, {0x0001, "Slow"}, {0, 0} }; value_map VID_CTRL_SPD_value_map[] = { {0x0000, "Medium"}, {0x0001, "Slow"}, {0, 0} }; value_map AC_OUT_SPD_value_map[] = { {0x0000, "Medium"}, {0x0001, "Slow"}, {0, 0} }; value_map SA_OUT_SPD_value_map[] = { {0x0000, "Medium"}, {0x0001, "Slow"}, {0, 0} }; value_map GEN_OUT_SPD_value_map[] = { {0x0000, "Medium"}, {0x0001, "Slow"}, {0, 0} }; value_map GPIO0_OUT_SEL_value_map[] = { {0x0000, "GPO[0]"}, {0x0001, "ACTIVE"}, {0x0008, "VACTIVE"}, {0x0009, "CBFLAG"}, {0x0040, "VID_DATA_EXT[0]"}, {0x0041, "VID_DATA_EXT[1]"}, {0x0048, "GPO[0]"}, {0x0049, "GPO[1]"}, {0x03e8, "GPO[2]"}, {0x03e9, "GPO[3]"}, {0x03f2, "IRQ_N/PRGM4"}, {0x03f3, "AC_SYNC"}, {0x044c, "AC_SDOUT"}, {0x044d, "PLL_CLK/PRGM7"}, {0x0456, "VRESET/HCTL/PRGM3"}, {0, 0} }; value_map GPIO1_OUT_SEL_value_map[] = { {0x0000, "GPO[1]"}, {0x0001, "ACTIVE"}, {0x0008, "VACTIVE"}, {0x0009, "CBFLAG"}, {0x0040, "VID_DATA_EXT[0]"}, {0x0041, "VID_DATA_EXT[1]"}, {0x0048, "GPO[0]"}, {0x0049, "GPO[1]"}, {0x03e8, "GPO[2]"}, {0x03e9, "GPO[3]"}, {0x03f2, "IRQ_N/PRGM4"}, {0x03f3, "AC_SYNC"}, {0x044c, "AC_SDOUT"}, {0x044d, "PLL_CLK/PRGM7"}, {0x0456, "VRESET/HCTL/PRGM3"}, {0, 0} }; value_map CHIPSEL_OUT_SEL_value_map[] = { {0x0000, "GPO[0]"}, {0x0001, "ACTIVE"}, {0x0008, "VACTIVE"}, {0x0009, "CBFLAG"}, {0x0040, "VID_DATA_EXT[0]"}, {0x0041, "VID_DATA_EXT[1]"}, {0x0048, "GPO[0]"}, {0x0049, "GPO[1]"}, {0x03e8, "GPO[2]"}, {0x03e9, "GPO[3]"}, {0x03f2, "IRQ_N/PRGM4"}, {0x03f3, "AC_SYNC"}, {0x044c, "AC_SDOUT"}, {0x044d, "PLL_CLK/PRGM7"}, {0x0456, "VRESET/HCTL/PRGM3"}, {0, 0} }; value_map IRQN_OUT_SEL_value_map[] = { {0x0000, "IRQ_N/PRGM4"}, {0x0001, "ACTIVE"}, {0x0008, "VACTIVE"}, {0x0009, "CBFLAG"}, {0x0040, "VID_DATA_EXT[0]"}, {0x0041, "VID_DATA_EXT[1]"}, {0x0048, "GPO[0]"}, {0x0049, "GPO[1]"}, {0x03e8, "GPO[2]"}, {0x03e9, "GPO[3]"}, {0x03f2, "IRQ_N/PRGM4"}, {0x03f3, "AC_SYNC"}, {0x044c, "AC_SDOUT"}, {0x044d, "PLL_CLK/PRGM7"}, {0x0456, "VRESET/HCTL/PRGM3"}, {0, 0} }; value_map IR_RX_OUT_SEL_value_map[] = { {0x0000, "GPO[2]"}, {0x0001, "ACTIVE"}, {0x0008, "VACTIVE"}, {0x0009, "CBFLAG"}, {0x0040, "VID_DATA_EXT[0]"}, {0x0041, "VID_DATA_EXT[1]"}, {0x0048, "GPO[0]"}, {0x0049, "GPO[1]"}, {0x03e8, "GPO[2]"}, {0x03e9, "GPO[3]"}, {0x03f2, "IRQ_N/PRGM4"}, {0x03f3, "AC_SYNC"}, {0x044c, "AC_SDOUT"}, {0x044d, "PLL_CLK/PRGM7"}, {0x0456, "VRESET/HCTL/PRGM3"}, {0, 0} }; value_map IR_TX_OUT_SEL_value_map[] = { {0x0000, "IR_TX/PRGM6"}, {0x0001, "ACTIVE"}, {0x0008, "VACTIVE"}, {0x0009, "CBFLAG"}, {0x0040, "VID_DATA_EXT[0]"}, {0x0041, "VID_DATA_EXT[1]"}, {0x0048, "GPO[0]"}, {0x0049, "GPO[1]"}, {0x03e8, "GPO[2]"}, {0x03e9, "GPO[3]"}, {0x03f2, "IRQ_N/PRGM4"}, {0x03f3, "AC_SYNC"}, {0x044c, "AC_SDOUT"}, {0x044d, "PLL_CLK/PRGM7"}, {0x0456, "VRESET/HCTL/PRGM3"}, {0, 0} }; value_map DVALID_PRGM0_OUT_SEL_value_map[] = { {0x0000, "DVALID"}, {0x0001, "ACTIVE"}, {0x0008, "VACTIVE"}, {0x0009, "CBFLAG"}, {0x0040, "VID_DATA_EXT[0]"}, {0x0041, "VID_DATA_EXT[1]"}, {0x0048, "GPO[0]"}, {0x0049, "GPO[1]"}, {0x03e8, "GPO[2]"}, {0x03e9, "GPO[3]"}, {0x03f2, "IRQ_N/PRGM4"}, {0x03f3, "AC_SYNC"}, {0x044c, "AC_SDOUT"}, {0x044d, "PLL_CLK/PRGM7"}, {0x0456, "VRESET/HCTL/PRGM3"}, {0, 0} }; value_map FIELD_PRGM1_OUT_SEL_value_map[] = { {0x0000, "FIELD"}, {0x0001, "ACTIVE"}, {0x0008, "VACTIVE"}, {0x0009, "CBFLAG"}, {0x0040, "VID_DATA_EXT[0]"}, {0x0041, "VID_DATA_EXT[1]"}, {0x0048, "GPO[0]"}, {0x0049, "GPO[1]"}, {0x03e8, "GPO[2]"}, {0x03e9, "GPO[3]"}, {0x03f2, "IRQ_N/PRGM4"}, {0x03f3, "AC_SYNC"}, {0x044c, "AC_SDOUT"}, {0x044d, "PLL_CLK/PRGM7"}, {0x0456, "VRESET/HCTL/PRGM3"}, {0, 0} }; value_map HRESET_PRGM2_OUT_SEL_value_map[] = { {0x0000, "HRESET"}, {0x0001, "ACTIVE"}, {0x0008, "VACTIVE"}, {0x0009, "CBFLAG"}, {0x0040, "VID_DATA_EXT[0]"}, {0x0041, "VID_DATA_EXT[1]"}, {0x0048, "GPO[0]"}, {0x0049, "GPO[1]"}, {0x03e8, "GPO[2]"}, {0x03e9, "GPO[3]"}, {0x03f2, "IRQ_N/PRGM4"}, {0x03f3, "AC_SYNC"}, {0x044c, "AC_SDOUT"}, {0x044d, "PLL_CLK/PRGM7"}, {0x0456, "VRESET/HCTL/PRGM3"}, {0, 0} }; value_map VRESET_HCTL_PRGM3_OUT_SEL_value_map[] = { {0x0000, "VRESET/HCTL/PRGM3"}, {0x0001, "ACTIVE"}, {0x0008, "VACTIVE"}, {0x0009, "CBFLAG"}, {0x0040, "VID_DATA_EXT[0]"}, {0x0041, "VID_DATA_EXT[1]"}, {0x0048, "GPO[0]"}, {0x0049, "GPO[1]"}, {0x03e8, "GPO[2]"}, {0x03e9, "GPO[3]"}, {0x03f2, "IRQ_N/PRGM4"}, {0x03f3, "AC_SYNC"}, {0x044c, "AC_SDOUT"}, {0x044d, "PLL_CLK/PRGM7"}, {0x0456, "VRESET/HCTL/PRGM3"}, {0, 0} }; value_map AC_OUT_SEL_value_map[] = { {0x0000, "GPO[3]. AC_SYNC, AC_SDOUT"}, {0, 0} }; value_map SA_OUT_OUT_SEL_value_map[] = { {0x0000, "SA_WCLK_OUT, SA_BCLK_OUT, GPO[2]"}, {0x0001, "AC_SYNC, AC_SDOUT, GPO[3]"}, {0, 0} }; value_map SA_IN_OUT_SEL_value_map[] = { {0x0000, "SA_WCLK_OUT, SA_BCLK_OUT, SA_SDOUT"}, {0x0001, "AC_SYNC, AC_SDOUT, GPO[3]"}, {0, 0} }; value_map AUX_PLL_AOUT_SEL_value_map[] = { {0x0001, "Auxiliary PLL"}, {0x0065, "Video PLL"}, {0, 0} }; value_map AUX_PLL_DOUT_SEL_value_map[] = { {0x0000, "PLL_CLK/PRGM7"}, {0x0001, "ACTIVE"}, {0x0008, "VACTIVE"}, {0x0009, "CBFLAG"}, {0x0040, "VID_DATA_EXT[0]"}, {0x0041, "VID_DATA_EXT[1]"}, {0x0048, "GPO[0]"}, {0x0049, "GPO[1]"}, {0x03e8, "GPO[2]"}, {0x03e9, "GPO[3]"}, {0x03f2, "IRQ_N/PRGM4"}, {0x03f3, "AC_SYNC"}, {0x044c, "AC_SDOUT"}, {0x044d, "PLL_CLK/PRGM7"}, {0x0456, "VRESET/HCTL/PRGM3"}, {0, 0} }; value_map AC_BITCLK_IN_SEL_value_map[] = { {0x0001, "DVALID/PRGM0"}, {0, 0} }; value_map AC_SDIN_IN_SEL_value_map[] = { {0x0000, "ground"}, {0x0001, "DVALID/PRGM0"}, {0, 0} }; value_map GPI0_IN_SEL_value_map[] = { {0x0000, "DVALID/PRGM0"}, {0x0001, "FIELD/PRGM1"}, {0x0008, "HRESET/PRGM2"}, {0x0009, "VRESET/HCTL/PRGM3"}, {0x0040, "IRQ_N/PRGM4"}, {0x0041, "IR_TX/PRGM6"}, {0x0048, "IR_RX/PRGM5"}, {0x0049, "GPI[0]"}, {0x03e8, "GPI[1]"}, {0x03e9, "SA_SDIN"}, {0x03f2, "SA_SDOUT"}, {0x03f3, "PLL_CLK/PRGM7"}, {0, 0} }; value_map GPI1_IN_SEL_value_map[] = { {0x0000, "DVALID/PRGM0"}, {0x0001, "FIELD/PRGM1"}, {0x0008, "HRESET/PRGM2"}, {0x0009, "VRESET/HCTL/PRGM3"}, {0x0040, "IRQ_N/PRGM4"}, {0x0041, "IR_TX/PRGM6"}, {0x0048, "IR_RX/PRGM5"}, {0x0049, "GPIO[0]/PRGM8"}, {0x03e8, "GPIO[1]/PRGM9"}, {0x03e9, "SA_SDIN"}, {0x03f2, "SA_SDOUT"}, {0x03f3, "PLL_CLK/PRGM7"}, {0, 0} }; value_map GPI2_IN_SEL_value_map[] = { {0x0000, "DVALID/PRGM0"}, {0x0001, "FIELD/PRGM1"}, {0x0008, "HRESET/PRGM2"}, {0x0009, "VRESET/HCTL/PRGM3"}, {0x0040, "IRQ_N/PRGM4"}, {0x0041, "IR_TX/PRGM6"}, {0x0048, "IR_RX/PRGM5"}, {0x0049, "GPIO[0]/PRGM8"}, {0x03e8, "GPIO[1]/PRGM9"}, {0x03e9, "SA_SDIN"}, {0x03f2, "SA_SDOUT"}, {0x03f3, "PLL_CLK/PRGM7"}, {0, 0} }; value_map GPI3_IN_SEL_value_map[] = { {0x0000, "DVALID/PRGM0"}, {0x0001, "FIELD/PRGM1"}, {0x0008, "HRESET/PRGM2"}, {0x0009, "VRESET/HCTL/PRGM3"}, {0x0040, "IRQ_N/PRGM4"}, {0x0041, "IR_TX/PRGM6"}, {0x0048, "IR_RX/PRGM5"}, {0x0049, "GPIO[0]/PRGM8"}, {0x03e8, "GPIO[1]/PRGM9"}, {0x03e9, "SA_SDIN"}, {0x03f2, "SA_SDOUT"}, {0x03f3, "PLL_CLK/PRGM7"}, {0, 0} }; value_map SA_MCLK_SEL_value_map[] = { {0x0000, "Use AUX_PLL_POST value to derive SA_MCLK."}, {0x0001, "PLL_CLK/PRGM7 is divided by the alternate post-divider"}, {0, 0} }; value_map PWR_DN_TUNING_value_map[] = { {0x0000, "Do not power down filter tuning"}, {0x0001, "Power down filter tuning"}, {0, 0} }; value_map PWR_DN_DLL1_value_map[] = { {0x0000, "Do not power down DLL1"}, {0x0001, "Power down DLL1"}, {0, 0} }; value_map PWR_DN_DLL2_value_map[] = { {0x0000, "Do not power down DLL2"}, {0x0001, "Power down DLL2"}, {0, 0} }; value_map PWR_DN_ADC1_value_map[] = { {0x0000, "Do not power down ADC1"}, {0x0001, "Power down ACD1"}, {0, 0} }; value_map PWR_DN_ADC2_value_map[] = { {0x0000, "Do not power down Miscellaneous Chip Control"}, {0x0001, "Power down ACD2"}, {0, 0} }; value_map PWR_DN_CH1_value_map[] = { {0x0000, "Do not power down Channel 1"}, {0x0001, "Power down Channel 1"}, {0, 0} }; value_map PWR_DN_CH2_value_map[] = { {0x0000, "Do not power down Channel 2"}, {0x0001, "Power down Channel 2"}, {0, 0} }; value_map PWR_DN_CH3_value_map[] = { {0x0000, "Do not power down Channel 3"}, {0x0001, "Power down Channel 3"}, {0, 0} }; value_map SLEEP_ANALOG_MSK_value_map[] = { {0x0000, "SLEEP powers down analog subsystem"}, {0x0001, "Power down of analog subsystem inhibited including DLL"}, {0, 0} }; value_map SLEEP_DLL_MSK_value_map[] = { {0x0000, "SLEEP powers down DLL (5x clock) circuitry"}, {0x0001, "Power down inhibited"}, {0, 0} }; value_map SLEEP_PLL_MSK_value_map[] = { {0x0000, "SLEEP powers down PLLs"}, {0x0001, "Power down of PLL inhibited"}, {0, 0} }; value_map VCLK_GATE_MSK_value_map[] = { {0x0000, "DIG_PWR_ON disables high-speed video clock (VCLK)"}, {0x0001, "Gating of VCLK inhibited"}, {0, 0} }; value_map CLK5x_GATE_MSK_value_map[] = { {0x0000, "DIG_PWR_ON disables high-speed audio clock (CLK5x)"}, {0x0001, "Gating of CLK5x inhibited"}, {0, 0} }; value_map SCLK_GATE_MSK_value_map[] = { {0x0000, "DIG_PWR_ON disables sample clock (SCLK) and SA master"}, {0x0001, "Gating of SCLK and SA_MCLK inhibited"}, {0, 0} }; value_map FOUR_X_CLK_ADC_value_map[] = { {0x0000, "5x output"}, {0x0001, "4x output"}, {0, 0} }; value_map VREG_D_1_0__value_map[] = { {0x0000, "1.20 V"}, {0x0001, "1.26 V"}, {0x000a, "1.32 V"}, {0x000b, "1.38 V"}, {0, 0} }; value_map VREF_CTRL_ADC_value_map[] = { {0x0000, "1.60 V"}, {0x0001, "1.20 V"}, {0, 0} }; value_map BIAS_CTRL_ADC_1_0__value_map[] = { {0x0000, "50 microA"}, {0x0001, "37.5 microA"}, {0x000a, "62.5 microA"}, {0x000b, "75 microA"}, {0, 0} }; value_map BIAS_CTRL_ADC_2__value_map[] = { {0x0000, "1.6 V, 0.8 V"}, {0x0001, "1.5 V, 0.9 V"}, {0, 0} }; value_map BIAS_CTRL_ADC_4_3__value_map[] = { {0x0000, "12.5 microA"}, {0x0001, "6.25 microA"}, {0x000a, "25 microA"}, {0x000b, "50 microA"}, {0, 0} }; value_map BIAS_CTRL_ADC_6_5__value_map[] = { {0x0000, "50 microA"}, {0x0001, "62.5 microA"}, {0x000a, "37.5 microA"}, {0x000b, "75 microA"}, {0, 0} }; value_map S2DIFF_BIAS_1_0__value_map[] = { {0x0000, "0.75"}, {0x0001, "1"}, {0x000a, "1.25"}, {0x000b, "1.5"}, {0, 0} }; value_map FILTER_BIAS_1_0__value_map[] = { {0x0000, "0.5"}, {0x0001, "1"}, {0x000a, "1.5"}, {0x000b, "2"}, {0, 0} }; value_map CH_SEL_ADC1_value_map[] = { {0x0000, "Connects ADC1 to output of filter."}, {0x0001, "Connects ADC1 to the output of first VGA stage."}, {0, 0} }; value_map DISCONNECT_CH1_value_map[] = { {0x0000, "Enable filter"}, {0x0001, "Disable filter"}, {0, 0} }; value_map TEST_MODE_CH1_value_map[] = { {0x0000, "Do not connect"}, {0x0001, "Connect"}, {0, 0} }; value_map FORCE_TUNING_value_map[] = { {0x0000, "Do not override"}, {0x0001, "Forces tuning code to value contained in TUNE_IN field."}, {0, 0} }; value_map TUNING_READY_value_map[] = { {0x0000, "Not complete"}, {0x0001, "Filter tuning complete"}, {0, 0} }; value_map VID_DUAL_FLAG_POL_value_map[] = { {0x0000, "Noninverted polarity"}, {0x0001, "Inverted polarity"}, {0, 0} }; value_map AUD_DUAL_FLAG_POL_value_map[] = { {0x0000, "Noninverted polarity"}, {0x0001, "Inverted polarity"}, {0, 0} }; value_map VID_PLL_DDS_value_map[] = { {0x0000, "Enable"}, {0x0001, "Disable"}, {0, 0} }; value_map AUX_PLL_DDS_value_map[] = { {0x0000, "Enable"}, {0x0001, "Disable"}, {0, 0} }; value_map VID_PLL_RST_value_map[] = { {0x0000, "Do not reset"}, {0x0001, "Reset the auxiliary PLL"}, {0, 0} }; value_map AUX_PLL_RST_value_map[] = { {0x0000, "Do not reset"}, {0x0001, "Reset the auxiliary PLL"}, {0, 0} }; value_map AUX_PLL_LOCK_value_map[] = { {0x0000, "Unlocked"}, {0x0001, "Locked"}, {0, 0} }; value_map VID_PLL_LOCK_value_map[] = { {0x0000, "Unlocked"}, {0x0001, "Locked"}, {0, 0} }; value_map AUX_PLL_UNLOCK_value_map[] = { {0x0000, "No unlock detected"}, {0x0001, "Unlock detected"}, {0, 0} }; value_map VID_PLL_UNLOCK_value_map[] = { {0x0000, "No unlock detected"}, {0x0001, "Unlock detected"}, {0, 0} }; value_map WIN_value_map[] = { {0x0000, "Next carrier edge predicted to be 16 RX clocks 3/+3"}, {0x0001, "Next carrier edge predicted to be 16 RX clocks 4/+3"}, {0x000a, "Next carrier edge predicted to be 16 RX clocks 3/+4"}, {0x000b, "Next carrier edge predicted to be 16 RX clocks 4/+4"}, {0, 0} }; value_map EDG_value_map[] = { {0x0000, "Disable"}, {0x0001, "Falling edges trigger RX filter/pulse timer start/stop"}, {0x000a, "Rising edges trigger RX filter/pulse timer start/stop"}, {0x000b, "Either edge trigger RX filter/pulse timer start/stop"}, {0, 0} }; value_map DMD_value_map[] = { {0x0000, "Disable receive carrier demodulation, receive data as simple logic"}, {0x0001, "Enable receive carrier demodulation, detect a mark as a series of"}, {0, 0} }; value_map MOD_value_map[] = { {0x0000, "Disable transmit carrier modulation, transmit data as simple logic"}, {0x0001, "Enable transmit carrier modulation, transmit a mark as a burst of"}, {0, 0} }; value_map RFE_value_map[] = { {0x0000, "Disable and reset receive FIFO to all 0s"}, {0x0001, "Enable receive FIFO"}, {0, 0} }; value_map TFE_value_map[] = { {0x0000, "Disable and reset transmit FIFO to all 0s"}, {0x0001, "Enable transmit FIFO"}, {0, 0} }; value_map RXE_value_map[] = { {0x0000, "Disable receiver"}, {0x0001, "Enable receiver"}, {0, 0} }; value_map TXE_value_map[] = { {0x0000, "Disable transmitter"}, {0x0001, "Enable transmitter"}, {0, 0} }; value_map RIC_value_map[] = { {0x0000, "Receive FIFO service interrupt/DMA request asserted when RX"}, {0x0001, "Receive FIFO service interrupt/DMA request asserted when RX"}, {0, 0} }; value_map TIC_value_map[] = { {0x0000, "Transmit FIFO service interrupt/DMA request asserted when TX"}, {0x0001, "Transmit FIFO service interrupt/DMA request asserted after"}, {0, 0} }; value_map CPL_value_map[] = { {0x0000, "If mod/demodulation enabled, 1s are transmitted and received as"}, {0x0001, "If mod/demodulation enabled, 1s transmitted and received as the"}, {0, 0} }; value_map LBM_value_map[] = { {0x0000, "Transmit and receive operation functions normally through the IR"}, {0x0001, "The output of the transmit modulation logic is fed into the input of"}, {0, 0} }; value_map R_value_map[] = { {0x0000, "Load Rx FIFO with 1s and Rx_data_lh level on timer overflow;"}, {0x0001, "Do not load Rx FIFO on timer overflow."}, {0, 0} }; value_map CDC_value_map[] = { {0x0000, "1 TX clock high and 15 TX clocks low"}, {0x0001, "2 TX clocks high and 14 TX clocks low"}, {0x0008, "3 TX clocks high and 13 TX clocks low"}, {0x044d, "14 TX clocks high and 2 TX clocks low"}, {0x0456, "15 TX clocks high and 1 TX clock low"}, {0x0457, "16 TX clocks high and 0 TX clocks low"}, {0, 0} }; value_map RTO_value_map[] = { {0x0000, "Receive pulse width counter has not reached its limit"}, {0x0001, "Receive pulse width counter has reached its limit (contains all 1s),"}, {0, 0} }; value_map ROR_value_map[] = { {0x0000, "Receive FIFO contains one or more empty entries or is full but has"}, {0x0001, "Receive FIFO has experienced an overrun, generate an irq request if"}, {0, 0} }; value_map TBY_value_map[] = { {0x0000, "Receiver is idle"}, {0x0000, "Transmitter is idle"}, {0x0001, "Receiver is busy"}, {0x0001, "Transmitter is busy"}, {0, 0} }; value_map RSR_value_map[] = { {0x0000, "If RIC=0 in IR_CNTL_REG, receive FIFO is less than half full. If"}, {0x0001, "IF RIC=0, receive FIFO is half full or more. If RIC=1, receive FIFO is"}, {0, 0} }; value_map TSR_value_map[] = { {0x0000, "If TIC=0 in IR_CNTL_REG, transmit FIFO is more than half full. If"}, {0x0001, "IF TIC=0, transmit FIFO is half full or less."}, {0, 0} }; value_map ROE_value_map[] = { {0x0000, "Receive FIFO overrun interrupt disabled"}, {0x0000, "Receive pulse width timer time-out interrupt disabled"}, {0x0001, "Receive FIFO overrun interrupt enabled"}, {0x0001, "Receive pulse width timer time-out interrupt enabled"}, {0, 0} }; value_map RSE_value_map[] = { {0x0000, "Receive FIFO interrupt disabled"}, {0x0001, "Receive FIFO interrupt enabled"}, {0, 0} }; value_map TSE_value_map[] = { {0x0000, "Transmit FIFO/Idle interrupt disabled"}, {0x0001, "Transmit FIFO/Idle interrupt enabled"}, {0, 0} }; value_map RXNDV_value_map[] = { {0x0000, "No more data in the RX FIFO"}, {0x0001, "One or more entries of valid data remain in RX FIFO"}, {0, 0} }; value_map VID_FMT_SEL_value_map[] = { {0x0000, "AUTO-DETECT"}, {0x0001, "NTSC-M"}, {0x0008, "NTSC-J"}, {0x0009, "NTSC-4.43"}, {0x0040, "PAL-BDGHI"}, {0x0041, "PAL-M"}, {0x0048, "PAL-N"}, {0x0049, "PAL-NC"}, {0x03e8, "PAL-60"}, {0x044c, "SECAM"}, {0, 0} }; value_map ACFG_DIS_value_map[] = { {0x0000, "Enable"}, {0x0001, "Disable"}, {0, 0} }; value_map AFD_PAL_SEL_value_map[] = { {0x0000, "PAL-BDGHI"}, {0x0001, "PAL-N"}, {0, 0} }; value_map AFD_NTSC_SEL_value_map[] = { {0x0000, "NTSC-M"}, {0x0001, "NTSC-J"}, {0, 0} }; value_map AFD_ACQUIRE_value_map[] = { {0x0000, "The auto-detect state machine operates normally."}, {0x0001, "The auto-detect state machine soft reset."}, {0, 0} }; value_map INPUT_MODE_value_map[] = { {0x0000, "CVBS"}, {0x0001, "Y/C"}, {0x000a, "Y/half-rate C"}, {0x000b, "Y/Pb/Pr"}, {0, 0} }; value_map MAN_SC_FAST_LOCK_value_map[] = { {0x0001, "Fast lock speed"}, {0, 0} }; value_map AUTO_SC_LOCK_value_map[] = { {0x0000, "Manual mode. Lock speed is determined by"}, {0x0001, "Auto Mode"}, {0, 0} }; value_map CKILLEN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map CAGCEN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map COMB_NOTCH_MODE_value_map[] = { {0x0000, "Disable notch filter. Comb only"}, {0x0001, "Notch data is interpreted as chroma"}, {0, 0} }; value_map CKILL_MODE_value_map[] = { {0x0000, "Chroma output is forced to 0, and luma output is generated"}, {0x0001, "Chroma output is forced to 0, entire chroma band is notched"}, {0, 0} }; value_map AFD_PALM_SEL_value_map[] = { {0x0000, "NTSC will be detected according to the AFD_NTSC_SEL bit."}, {0x0001, "PAL-M format is chosen when 525 lines and a 3.58 carrier"}, {0x000a, "Enable algorithm to dynamically detect between NTSC-M"}, {0, 0} }; value_map AFD_FORCE_PAL_value_map[] = { {0x0000, "The auto-detect algorithm proceeds normally."}, {0x0001, "PAL-BG/PAL-N is chosen when a 625-line format is detected."}, {0, 0} }; value_map AFD_FORCE_PALNC_value_map[] = { {0x0000, "The auto-detect algorithm proceeds normally."}, {0x0001, "PAL-Nc is chosen when a 625-line format is detected"}, {0, 0} }; value_map AFD_FORCE_SECAM_value_map[] = { {0x0000, "The auto-detect algorithm proceeds normally."}, {0x0001, "SECAM is chosen when a 625-line format is detected."}, {0, 0} }; value_map AFD_PAL60_DIS_value_map[] = { {0x0000, "PAL-60 can be detected and discriminate from NTSC-4.43"}, {0x0001, "Any 525-line 4.43 format is assumed to be NTSC-4.43."}, {0, 0} }; value_map OUT_MODE_value_map[] = { {0x0000, "ITU-R BT.601 coded video Synchronous Pixel Interface"}, {0x0001, "ITU-R BT.656 control codes"}, {0x000a, "VIP 1.1 control codes"}, {0x000b, "VIP 2 control codes"}, {0, 0} }; value_map MODE10B_value_map[] = { {0x0000, "Luma and Chroma Output are rounded to 8 bits"}, {0x0001, "Luma and Chroma Output have 10 bits of resolution"}, {0, 0} }; value_map VBIHACTRAW_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map ANC_DATA_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map BLUE_FIELD_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map CLAMPRAW_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map SWAPRAW_value_map[] = { {0x0000, "Even samples on chroma; odd samples on luma"}, {0x0001, "Odd samples on chroma; even samples on luma"}, {0, 0} }; value_map ACTFMT_value_map[] = { {0x0000, "Active is composite active"}, {0x0001, "Active is horizontal active"}, {0, 0} }; value_map VALIDFMT_value_map[] = { {0x0000, "Valid indicates nonscaled pixels"}, {0x0001, "Valid is logical AND of nominal VALID and ACTIVE, where"}, {0, 0} }; value_map HSFMT_value_map[] = { {0x0000, "Nominal width"}, {0x0001, "One pixel clock (VOF_PIXCLK) pulse wide"}, {0, 0} }; value_map CLK_GATING_value_map[] = { {0x000a, "Gate with VALID output"}, {0x000b, "Gate with logical AND of VALID and ACTIVE outputs"}, {0, 0} }; value_map DCMODE_value_map[] = { {0x0000, "Data Count is number of blocks of 4 UDWs, with padding"}, {0x0001, "Data Count is number UDWs"}, {0, 0} }; value_map IDID0_SOURCE_value_map[] = { {0x0000, "IDID0 register"}, {0x0001, "Line Count from VBI Slicer"}, {0, 0} }; value_map VIP_OPT_AL_value_map[] = { {0x0000, "VBLANK"}, {0x0001, "V656BLANK"}, {0, 0} }; value_map VIPBLANK_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map VIPCLAMP_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map AUD_ANC_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map SAMPLE_RATE_value_map[] = { {0x0000, "48 kHz"}, {0x0001, "44.1 kHz"}, {0x000a, "32 kHz"}, {0x000b, "Reserved"}, {0, 0} }; value_map AUD_GRP_value_map[] = { {0x0000, "Audio Group1"}, {0x0001, "Audio Group2"}, {0x000a, "Audio Group3"}, {0x000b, "Audio Group4"}, {0, 0} }; value_map AFD_FMT_STAT_value_map[] = { {0x0001, "NTSC-M"}, {0x0002, "NTSC-J"}, {0x0003, "NTSC-4.43"}, {0x0004, "PAL-BDGHI"}, {0x0005, "PAL-M"}, {0x0006, "PAL-N"}, {0x0007, "PAL-NC"}, {0x0008, "PAL-60"}, {0x000c, "SECAM"}, {0, 0} }; value_map PEAK_SEL_value_map[] = { {0x0000, "+2.0 dB response @ center freq"}, {0x0001, "+3.5 dB response @ center freq"}, {0x000a, "+5.0 dB response @ center freq"}, {0x000b, "+6.0 dB response @ center freq"}, {0, 0} }; value_map PEAK_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map RANGE_value_map[] = { {0x0000, "Range: 641016 Nominal 656 range with excursions"}, {0x0001, "Range: 41016 Nominal 656 range with excursions allowed"}, {0, 0} }; value_map LUMA_CORE_SEL_value_map[] = { {0x0000, "No coring"}, {0x0001, "Coring threshold set to + 16"}, {0x000a, "Coring threshold set to + 32"}, {0x000b, "Coring threshold set to + 64"}, {0, 0} }; value_map HFILT_value_map[] = { {0x0000, "Auto Mode"}, {0x0001, "CIF"}, {0x000a, "QCIF"}, {0x000b, "ICON"}, {0, 0} }; value_map VFILT_value_map[] = { {0x0000, "2-tap interpolation (available at all resolutions)"}, {0x0001, "3-tap interpolation (available if scaling to less than 385"}, {0x0008, "4-tap interpolation (available if scaling to less than 193"}, {0x0009, "5-tap interpolation (available if scaling to less than 193"}, {0, 0} }; value_map VS_INTRLACE_value_map[] = { {0x0000, "Noninterlace VS"}, {0x0001, "Interlace VS"}, {0, 0} }; value_map LINE_AVG_DIS_value_map[] = { {0x0000, "PAL line averaging is enabled. Adjacent lines are averaged"}, {0x0001, "PAL line averaging is disabled."}, {0, 0} }; value_map C_CORE_SEL_value_map[] = { {0x0000, "No coring"}, {0x0001, "+7"}, {0x000a, "+15"}, {0x000b, "+31"}, {0, 0} }; value_map CHR_DELAY_value_map[] = { {0x0000, "0"}, {0x0001, "+1"}, {0x0008, "+2"}, {0x006e, "2"}, {0x006f, "1"}, {0, 0} }; value_map VBI_MD_LINE1_value_map[] = { {0x0000, "No VBI data slicing"}, {0x0000, "No VBI data slicing"}, {0x0001, "WST525-B"}, {0x0001, "WST625-B"}, {0x0008, "WST525-C (NABTS)"}, {0x0008, "WST625-A"}, {0x0009, "WST525-D (Moji)"}, {0x0040, "WSS525"}, {0x0040, "WSS625"}, {0x0041, "VITC525"}, {0x0041, "VITC625"}, {0x0048, "CC525"}, {0x0066, "CC525"}, {0x0048, "CC625"}, {0x0049, "Gemstar 1x"}, {0x0049, "VPS"}, {0x03e8, "Gemstar 2x"}, {0x03e9, "Custom VBI1"}, {0x03e9, "Custom VBI1"}, {0x03f2, "Custom VBI2"}, {0x03f2, "Custom VBI2"}, {0x03f3, "Custom VBI3"}, {0x03f3, "Custom VBI3"}, {0, 0} }; value_map FC_SEARCH_MODE_value_map[] = { {0x0000, "Frame code match is declared only if frame code (start code,"}, {0x0001, "Frame code match is declared upon discovering the first bit"}, {0, 0} }; value_map ADAPT_SLICE_DIS_value_map[] = { {0x0000, "Slice level comes from averaging points in the clock run-in."}, {0x0001, "Slice level is set to predetermined level based on mode."}, {0, 0} }; value_map EDGE_RESYNC_EN_value_map[] = { {0x0000, "Sample point timing is determined by initial edge"}, {0x0001, "Sample point timing is resynchronized upon detecting any"}, {0, 0} }; value_map CRI_MARG_SCALE_value_map[] = { {0x0000, "Divide default timing margin by 2"}, {0x0001, "Use default timing margin"}, {0x000a, "Multiply default timing margin by 2"}, {0x000b, "Multiply default timing margin by 4"}, {0, 0} }; value_map VPS_DEC_DIS_value_map[] = { {0x0000, "VPS formats are decoded based on a two-bit biphase pattern."}, {0x0001, "Raw slice bits are transmitted"}, {0, 0} }; value_map MOJI_PACK_DIS_value_map[] = { {0x0000, "WST525, system D formats cause the decoder to extract the"}, {0x0001, "The WST 525, system D bit stream is packed into byte"}, {0, 0} }; value_map VBI1_FORMAT_TYPE_value_map[] = { {0x0009, "Enable Moji style byte alignment: First six bits go into"}, {0x0040, "Wide-screen signaling: Assume signal includes single"}, {0x0040, "Wide-screen signaling: Implement WSS625 style"}, {0x0041, "VITC: Assume sync pulses every 8 bits"}, {0x03e9, "VPS: Implement VPS style biphase decoding"}, {0, 0} }; value_map VBI1_FIFO_MODE_value_map[] = { {0x0000, "Do not load to payload FIFO"}, {0x0001, "Load to Gemstar 1x FIFO"}, {0x0008, "Load to CC FIFO"}, {0x0009, "Load to WSS FIFO"}, {0x0064, "Load to Gemstar 2x FIFO"}, {0, 0} }; value_map VBI2_FORMAT_TYPE_value_map[] = { {0x0009, "Enable Moji style byte alignment: First six bits go into"}, {0x0040, "Wide-screen signaling: Assume signal includes single"}, {0x0040, "Wide-screen signaling: Implement WSS625 style"}, {0x0041, "VITC: Assume sync pulses every 8 bits"}, {0x03e9, "VPS: Implement VPS style biphase decoding"}, {0, 0} }; value_map VBI2_FIFO_MODE_value_map[] = { {0x0000, "Do not load to payload FIFO"}, {0x0001, "Load to Gemstar 1x FIFO"}, {0x0008, "Load to CC FIFO"}, {0x0009, "Load to WSS FIFO"}, {0x0064, "Load to Gemstar 2x FIFO"}, {0, 0} }; value_map VBI3_FORMAT_TYPE_value_map[] = { {0x0009, "Enable Moji style byte alignment: First six bits go into"}, {0x0040, "Wide-screen signaling: Assume signal includes single"}, {0x0040, "Wide-screen signaling: Implement WSS625 style"}, {0x0041, "VITC: Assume sync pulses every 8 bits"}, {0x03e9, "VPS: Implement VPS-style biphase decoding"}, {0, 0} }; value_map VBI3_FIFO_MODE_value_map[] = { {0x0000, "Do not load to payload FIFO"}, {0x0001, "Load to Gemstar 1x FIFO"}, {0x0008, "Load to CC FIFO"}, {0x0009, "Load to WSS FIFO"}, {0x0064, "Load to Gemstar 2x FIFO"}, {0, 0} }; value_map UV_LPF_SEL_value_map[] = { {0x0000, "Low (~600 kHz)"}, {0x0001, "Medium (~1 MHz)"}, {0x000a, "High (~1.5 MHz)"}, {0, 0} }; value_map LUMA_LPF_SEL_value_map[] = { {0x0000, "Low (~600 kHz)"}, {0x0001, "Medium (~1 MHz)"}, {0x000a, "High (~1.5 MHz)"}, {0, 0} }; value_map LCOMB_2LN_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map LCOMB_3LN_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map CCOMB_2LN_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map CCOMB_3LN_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map TDALGN_value_map[] = { {0x0000, "Start on odd field"}, {0x0001, "Start on even field"}, {0, 0} }; value_map HR32_value_map[] = { {0x0000, "HRESET is 64 clocks wide"}, {0x0001, "HRESET is 32 clocks wide"}, {0, 0} }; value_map VPRES_VERT_EN_value_map[] = { {0x0000, "VPRES reflects the horizontal locking only."}, {0x0001, "VPRES status bit reflects when the video is both locked"}, {0, 0} }; value_map VT_LINE_CNT_HYST_value_map[] = { {0x0000, "2 consecutive fields with approximately 525/2 or 625/2"}, {0x0001, "4 consecutive fields with approximately 525/2 or 625/2"}, {0x000a, "8 consecutive fields with approximately 525/2 or 625/2"}, {0x000b, "16 consecutive fields with approximately 525/2 or 625/2"}, {0, 0} }; value_map DEBOUNCE_COUNT_value_map[] = { {0x0000, "2 consecutive fields of stability"}, {0x0001, "4 consecutive fields of stability"}, {0x000a, "8 consecutive fields of stability"}, {0x000b, "16 consecutive fields of stability"}, {0, 0} }; value_map VGA_AUTO_EN_value_map[] = { {0x0000, "Freeze/manual"}, {0x0001, "Auto mode"}, {0, 0} }; value_map AGC_AUTO_EN_value_map[] = { {0x0000, "Freeze/manual"}, {0x0001, "Auto mode"}, {0, 0} }; value_map CLAMP_AUTO_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map MAJ_SEL_value_map[] = { {0x0000, " maximum luma"}, {0x0001, " maximum luma"}, {0x000a, " maximum luma"}, {0x000b, "Automatic"}, {0, 0} }; value_map MAJ_SEL_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map CRUSH_FREQ_value_map[] = { {0x0000, "Field rate"}, {0x0001, "Frame rate"}, {0, 0} }; value_map WTW_EN_value_map[] = { {0x0000, "100 IRE peak threshold"}, {0x0001, "110 IRD peak threshold"}, {0, 0} }; value_map APL_DETECT_ENA_value_map[] = { {0x0000, "This special case is not detected. The white line will be"}, {0x0001, "Forces the Y/C separation algorithm into notch mode"}, {0, 0} }; value_map DL_AUTO_INC_value_map[] = { {0x0000, "Auto increment address on write"}, {0x0001, "Auto increment address on read"}, {0, 0} }; value_map DL_ENABLE_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map START_MICROCNTL_value_map[] = { {0x0001, "Embedded microcontroller is running"}, {0, 0} }; value_map PREF_MODE_value_map[] = { {0x0000, "Mono/Language A: If mono, play mono; if dual or NICAM"}, {0x0001, "Language B: If dual or NICAM TRIVOX, play language B; if"}, {0, 0} }; value_map MUTE_NO_PREF_MODE_value_map[] = { {0x0001, "Mute output if preferred mode is not available."}, {0, 0} }; value_map DE_EMPHASIS_TIME_value_map[] = { {0x0001, "50 micro seconds"}, {0, 0} }; value_map FM_DEVIATION_value_map[] = { {0x0000, "Normal FM"}, {0x0001, "High deviation FMup to 360 kHz"}, {0x000a, "Very high deviation FMup to 540 kHz"}, {0, 0} }; value_map FORMAT_45MHZ_value_map[] = { {0x0000, "Chroma"}, {0x0001, "BTSC"}, {0x0008, "EIAJ"}, {0x0009, "A2-M"}, {0x0064, "Auto-detect"}, {0, 0} }; value_map FORMAT_65MHZ_value_map[] = { {0x0000, "System DK"}, {0x0001, "System L"}, {0x000a, "Auto-detect"}, {0, 0} }; value_map TUNER_OUTPUT_FORMAT_value_map[] = { {0x0000, "2nd IF"}, {0x0001, "AF"}, {0, 0} }; value_map AC97_INT_DIS_value_map[] = { {0x0001, "Disable"}, {0, 0} }; value_map AMC_INT_DIS_value_map[] = { {0x0001, "Disable"}, {0, 0} }; value_map FC_INT_DIS_value_map[] = { {0x0001, "Disable"}, {0, 0} }; value_map FDL_INT_DIS_value_map[] = { {0x0001, "Disable"}, {0, 0} }; value_map IFL_INT_DIS_value_map[] = { {0x0001, "Disable"}, {0, 0} }; value_map NLL_INT_DIS_value_map[] = { {0x0001, "Disable"}, {0, 0} }; value_map NBER_INT_DIS_value_map[] = { {0x0001, "Disable"}, {0, 0} }; value_map RDS_INT_DIS_value_map[] = { {0x0001, "Disable"}, {0, 0} }; value_map AAGC_GAIN_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map AAGC_DEFAULT_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map AFE_12DB_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map IF_SRC_MODE_value_map[] = { {0x0000, "TV audio input"}, {0x0001, "FM radio input"}, {0, 0} }; value_map PH_CH_SEL_value_map[] = { {0x0000, "Channel 1"}, {0x0001, "Channel 2"}, {0, 0} }; value_map DEMATRIX_MODE_value_map[] = { {0x0001, "Dematrix Sum/R"}, {0, 0} }; value_map DMTRX_BYPASS_value_map[] = { {0x0000, "System decide dematrix mode"}, {0x0001, "Force Dematrix block use mode set above"}, {0, 0} }; value_map PATH1_AVC_CR_value_map[] = { {0x0000, "2:1"}, {0x0001, "4:1"}, {0x0008, "8:1"}, {0x0009, "16:1"}, {0x0064, "32:1"}, {0, 0} }; value_map PATH1_AVC_STEREO_value_map[] = { {0x0001, "Stereo Mode"}, {0, 0} }; value_map PATH1_AVC_AT_value_map[] = { {0x0000, "0"}, {0x0001, "10 ms"}, {0x0008, "20 ms"}, {0x0009, "100 ms"}, {0x0040, "500 ms"}, {0x0041, "1 s"}, {0x0048, "2 s"}, {0x0049, "4 s"}, {0x03e8, "8 s"}, {0, 0} }; value_map PATH1_AVC_RT_value_map[] = { {0x0000, "0"}, {0x0001, "10 ms"}, {0x0008, "20 ms"}, {0x0009, "100 ms"}, {0x0040, "500 ms"}, {0x0041, "1s"}, {0x0048, "2s"}, {0x0049, "4s"}, {0x03e8, "8s"}, {0, 0} }; value_map PATH1_AVC_CG_value_map[] = { {0x0000, "1"}, {0x0001, "1.5"}, {0x000a, "2"}, {0x000b, "4"}, {0, 0} }; value_map SOFT1_MUTE_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map SRC1_MUTE_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map SA_MUTE_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map PAR_MUTE_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map AC97_MUTE_EN_value_map[] = { {0x0000, "Disable"}, {0x0001, "Enable"}, {0, 0} }; value_map PATH1_EQ_BAND_SEL_value_map[] = { {0x0000, "500 Hz, 1 kHz, 2 kHz"}, {0x0001, "450 Hz, 1.5 kHz, 5 kHz"}, {0, 0} }; value_map PATH1_SC_RMS_CON_value_map[] = { {0x0000, "0"}, {0x0001, "10 ms"}, {0x0008, "20 ms"}, {0x0009, "100 ms"}, {0x0040, "500 ms"}, {0x0041, "1 s"}, {0x0048, "2 s"}, {0x0049, "4 s"}, {0x0457, "8 s"}, {0, 0} }; value_map PATH1_SC_CR_value_map[] = { {0x0000, "2:1"}, {0x0001, "4:1"}, {0x0008, "8:1"}, {0x0009, "16:1"}, {0x0064, "32:1"}, {0, 0} }; value_map PATH1_SC_STEREO_value_map[] = { {0x0001, "Stereo Mode"}, {0, 0} }; value_map PATH1_SC_AT_value_map[] = { {0x0000, "0"}, {0x0001, "10 ms"}, {0x0008, "20 ms"}, {0x0009, "100 ms"}, {0x0040, "500 ms"}, {0x0041, "1 s"}, {0x0048, "2 s"}, {0x0049, "4 s"}, {0x03e8, "8 s"}, {0, 0} }; value_map PATH1_SC_RT_value_map[] = { {0x0000, "0"}, {0x0001, "10 ms"}, {0x0008, "20 ms"}, {0x0009, "100 ms"}, {0x0040, "500 ms"}, {0x0041, "1 s"}, {0x0048, "2 s"}, {0x0049, "4 s"}, {0x03e8, "8 s"}, {0, 0} }; value_map PATH2_AVC_CR_value_map[] = { {0x0000, "2:1"}, {0x0001, "4:1"}, {0x0008, "8:1"}, {0x0009, "16:1"}, {0x0064, "32:1"}, {0, 0} }; value_map PATH2_AVC_STEREO_value_map[] = { {0x0001, "Stereo Mode"}, {0, 0} }; value_map PATH2_AVC_AT_value_map[] = { {0x0000, "0"}, {0x0001, "10 ms"}, {0x0008, "20 ms"}, {0x0009, "100 ms"}, {0x0040, "500 ms"}, {0x0041, "1 s"}, {0x0048, "2 s"}, {0x0049, "4 s"}, {0x03e8, "8 s"}, {0, 0} }; value_map PATH2_AVC_RT_value_map[] = { {0x0000, "0"}, {0x0001, "10 ms"}, {0x0008, "20 ms"}, {0x0009, "100 ms"}, {0x0040, "500 ms"}, {0x0041, "1 s"}, {0x0048, "2 s"}, {0x0049, "4 s"}, {0x03e8, "8 s"}, {0, 0} }; value_map PATH2_AVC_CG_value_map[] = { {0x0000, "1"}, {0x0001, "1.5"}, {0x000a, "2"}, {0x000b, "4"}, {0, 0} }; value_map PATH2_EQ_BAND_SEL_value_map[] = { {0x0000, "500 Hz, 1 kHz, 2 kHz"}, {0x0001, "450 Hz, 1.5 kHz, 5 kHz"}, {0, 0} }; value_map PATH2_SC_RMS_CON_value_map[] = { {0x0000, "0"}, {0x0001, "10 ms"}, {0x0008, "20 ms"}, {0x0009, "100 ms"}, {0x0040, "500 ms"}, {0x0041, "1 s"}, {0x0048, "2 s"}, {0x0049, "4 s"}, {0x0457, "8 s"}, {0, 0} }; value_map PATH2_SC_CR_value_map[] = { {0x0000, "2:1"}, {0x0001, "4:1"}, {0x0008, "8:1"}, {0x0009, "16:1"}, {0x0064, "32:1"}, {0, 0} }; value_map PATH2_SC_STEREO_value_map[] = { {0x0001, "Stereo Mode"}, {0, 0} }; value_map PATH2_SC_AT_value_map[] = { {0x0000, "0"}, {0x0001, "10 ms"}, {0x0008, "20 ms"}, {0x0009, "100 ms"}, {0x0040, "500 ms"}, {0x0041, "1 s"}, {0x0048, "2 s"}, {0x0049, "4 s"}, {0x03e8, "8 s"}, {0, 0} }; value_map PATH2_SC_RT_value_map[] = { {0x0000, "0"}, {0x0001, "10 ms"}, {0x0008, "20 ms"}, {0x0009, "100 ms"}, {0x0040, "500 ms"}, {0x0041, "1 s"}, {0x0048, "2 s"}, {0x0049, "4 s"}, {0x03e8, "8 s"}, {0, 0} }; value_map PARALLEL1_SRC_SEL_value_map[] = { {0x0000, "Select from SRC 3"}, {0x0001, "Select from SRC 4"}, {0x000a, "Select from SRC 5"}, {0x000b, "Select from SRC 6"}, {0, 0} }; value_map PARALLEL2_SRC_SEL_value_map[] = { {0x0000, "Select from SRC 3"}, {0x0001, "Select from SRC 4"}, {0x000a, "Select from SRC 5"}, {0x000b, "Select from SRC 6"}, {0, 0} }; value_map SERIAL_AUDIO_SRC_SEL_value_map[] = { {0x0000, "Select from SRC 3"}, {0x0001, "Select from SRC 4"}, {0x000a, "Select from SRC 5"}, {0x000b, "Select from SRC 6"}, {0, 0} }; value_map AC97_SRC_SEL_value_map[] = { {0x0000, "Select from SRC 3"}, {0x0001, "Select from SRC 4"}, {0x000a, "Select from SRC 5"}, {0x000b, "Select from SRC 6"}, {0, 0} }; value_map BASEBAND_BYPASS_CTL_value_map[] = { {0x0000, "Normal operation"}, {0x0000, "Path1 automatic volume control"}, {0x0001, "Path1 equalizer"}, {0x0001, "The block is bypassed"}, {0, 0} }; value_map SRC3_CLK_SEL_value_map[] = { {0x0000, "Select from serial audio WS"}, {0x0001, "Select from AC97 RD (48 kHz)"}, {0x000a, "Select from NICAM ENABLE (64 kHz)"}, {0x000b, "Select from SRC3 FIFO write"}, {0, 0} }; value_map SRC3_IN_SEL_value_map[] = { {0x0000, "Select from path 1 output"}, {0x0001, "Select from path 2 output"}, {0x000a, "Select from dematrix stereo"}, {0x000b, "Select from mono output"}, {0, 0} }; value_map SRC4_CLK_SEL_value_map[] = { {0x0000, "Select from serial audio WS"}, {0x0001, "Select from AC97 RD (48 kHz)"}, {0x000a, "Select from NICAM ENABLE (64 kHz)"}, {0x000b, "Select from SRC4 FIFO write"}, {0, 0} }; value_map SRC4_IN_SEL_value_map[] = { {0x0000, "Select from path 1 output"}, {0x0001, "Select from path 2 output"}, {0x000a, "Select from dematrix stereo"}, {0x000b, "Select from mono output"}, {0, 0} }; value_map SRC5_CLK_SEL_value_map[] = { {0x0000, "Select from serial audio WS"}, {0x0001, "Select from AC97 RD (48 kHz)"}, {0x000a, "Select from NICAM ENABLE (64 kHz)"}, {0x000b, "Select from SRC5 FIFO write"}, {0, 0} }; value_map SRC5_IN_SEL_value_map[] = { {0x0000, "Select from analog demod outa, outc"}, {0x0001, "Select from analog demod RDS output"}, {0x000a, "Select from dematrix stereo"}, {0x000b, "Select from mono output"}, {0, 0} }; value_map SRC6_CLK_SEL_value_map[] = { {0x0000, "Select from serial audio WS"}, {0x0001, "Select from AC97 RD (48 kHz)"}, {0x000a, "Select from NICAM ENABLE (64 kHz)"}, {0x000b, "Select from SRC6 FIFO write"}, {0, 0} }; value_map SRC6_IN_SEL_value_map[] = { {0x0000, "Select from path 1 output"}, {0x0001, "Select from path 2 output"}, {0x000a, "Select from dematrix stereo"}, {0x000b, "Select from mono output"}, {0, 0} }; value_map SA_IN_WS_SEL_value_map[] = { {0x0000, "Left sample on SA_WCLK = 0"}, {0x0001, "Left sample on SA_WCLK = 1"}, {0, 0} }; value_map SA_IN_RIGHT_JUST_value_map[] = { {0x0001, "Right justified serial data"}, {0, 0} }; value_map SA_IN_SONY_MODE_value_map[] = { {0x0001, "Sony mode: 1st SA_BCLK_IN rising edge after"}, {0, 0} }; value_map SA_IN_MASTER_MODE_value_map[] = { {0x0001, "Master: SA_BCLK_IN and SA_WCLK_IN are"}, {0, 0} }; value_map SA_OUT_WS_SEL_value_map[] = { {0x0000, "Left sample on SA_WCLK = 0"}, {0x0001, "Left sample on SA_WCLK = 1"}, {0, 0} }; value_map SA_OUT_RIGHT_JUST_value_map[] = { {0x0001, "Right justified serial data"}, {0, 0} }; value_map SA_OUT_SONY_MODE_value_map[] = { {0x0001, "Sony mode: 1st SA_BCLK_OUT rising edge after"}, {0, 0} }; value_map SA_OUT_MASTER_MODE_value_map[] = { {0x0001, "Master: SA_BCLK_OUT, and SA_WCLK_OUT are"}, {0, 0} }; value_map AC97_UP2X_BYPASS_value_map[] = { {0x0001, "Up sample by 2 block is bypassed. Use for input"}, {0, 0} }; value_map ACLMSTR_BIT1_value_map[] = { {0x0000, "AC_LINK interface disabled"}, {0x0001, "AC_LINK interface enabled"}, {0, 0} }; value_map ACLMSTR_4TO2_3_2__value_map[] = { {0x0000, "Disable"}, {0x0001, "interrupt on any valid GPIO input slot"}, {0x000a, "interrupt on valid GPIO input slot if data changed"}, {0, 0} }; value_map ACLMSTR_4TO2_4__value_map[] = { {0x0000, "Disable"}, {0x0001, "interrupt after transfer"}, {0, 0} }; value_map ACLMSTR_12TO8_8___value_map[] = { {0x0000, "Disable"}, {0x0001, "interrupt on any valid stat slot"}, {0x000a, "interrupt on valid status slot if data changed"}, {0, 0} }; value_map ACLMSTR_12TO8_9__value_map[] = { {0x0000, "Disable"}, {0x0001, "interrupt after transfer"}, {0, 0} }; value_map ACLMSTR_12TO8_10__value_map[] = { {0x0000, "Disable"}, {0x0001, "interrupt at tag arrival"}, {0, 0} }; value_map ACLCTRL01_1_0__value_map[] = { {0x0000, "Disable"}, {0x0001, "16-bit mono/packed"}, {0x000a, "16-bit mono"}, {0x000b, "16-bit stereo"}, {0, 0} }; value_map ACLCTRL02_1_0__value_map[] = { {0x0000, "Disable"}, {0x0001, "16-bit mono/packed"}, {0x000a, "16-bit mono"}, {0, 0} }; value_map ACLCTRL03_1_0__value_map[] = { {0x0000, "Disable"}, {0x0001, "16-bit mono/packed"}, {0x000a, "16-bit mono"}, {0, 0} }; value_map ACLCTRL04_1_0__value_map[] = { {0x0000, "Disable"}, {0x0001, "16-bit mono/packed"}, {0x000a, "16-bit mono"}, {0, 0} }; value_map ACLCTRL06_1_0__value_map[] = { {0x0000, "Disable"}, {0x0001, "16-bit mono/packed"}, {0x000a, "16-bit mono"}, {0x000b, "16-bit stereo"}, {0, 0} }; value_map ACLCTRL07_1_0__value_map[] = { {0x0000, "Disable"}, {0x0001, "16-bit mono/packed"}, {0x000a, "16-bit mono"}, {0, 0} }; value_map ACLCTRL08_1_0__value_map[] = { {0x0000, "Disable"}, {0x0001, "16-bit mono/packed"}, {0x000a, "16-bit mono"}, {0, 0} }; #define DEFINE_SETTING_ENTRY(name, rname, sbit, bitl, type, default, vptr, des) { (((rname)&0x1ff)<<0)|(((sbit)&0x7)<<9)|(((bitl)&0x1f)<<12)|(((type)&0xf)<<17), default, name, vptr, des } cx25840_setting_entry cx25840_settings[] = { DEFINE_SETTING_ENTRY("SLEEP", Host_Register_1, 0, 1, RW, 0x0000, SLEEP_value_map, "Put the chip in sleep mode. Gate the digital clocks and power"), DEFINE_SETTING_ENTRY("DIGITAL_PWR_DN", Host_Register_1, 1, 1, RW, 0x0000, DIGITAL_PWR_DN_value_map, "Gate digital clocks (sclk, vclk, clkx5). This bit can be configured"), DEFINE_SETTING_ENTRY("REF_CLK_SEL", Host_Register_1, 2, 1, RW, 0x0001, REF_CLK_SEL_value_map, "Crystal clock input type select."), DEFINE_SETTING_ENTRY("PWR_DN_VID_PLL", Host_Register_1, 3, 1, RW, 0x0000, PWR_DN_VID_PLL_value_map, "Power down the Video Clock PLL."), DEFINE_SETTING_ENTRY("PWR_DN_AUX_PLL", Host_Register_1, 4, 1, RW, 0x0000, PWR_DN_AUX_PLL_value_map, "Power down the Auxiliary PLL."), DEFINE_SETTING_ENTRY("AUTO_INC_DIS", Host_Register_1, 5, 1, RW, 0x0000, AUTO_INC_DIS_value_map, "Control auto-address increment after each byte transfer."), DEFINE_SETTING_ENTRY("SLV_SI_DIS", Host_Register_1, 6, 1, RW, 0x0000, SLV_SI_DIS_value_map, "Control the glitch filters and slew rate control in the 12C pads to"), DEFINE_SETTING_ENTRY("FORCE_CHIP_SEL_VIPCLK", Host_Register_1, 7, 1, RW, 0x0000, FORCE_CHIP_SEL_VIPCLK_value_map, "Override the CHIP_SEL/VIPCLK pin for 12C address decode."), DEFINE_SETTING_ENTRY("PREFETCH_EN", Host_Register_2, 0, 1, RW, 0x0000, PREFETCH_EN_value_map, "Enables prefetch on reads. Prefetch is unnecessary unless the"), DEFINE_SETTING_ENTRY("PWR_DN_PLL_REG1", Host_Register_2, 1, 1, RW, 0x0000, 0, "Powers down the regulator for the video clock PLL."), DEFINE_SETTING_ENTRY("PWR_DN_PLL_REG2", Host_Register_2, 2, 1, RW, 0x0000, 0, "Powers down the regulator for the auxiliary clock PLL."), DEFINE_SETTING_ENTRY("DEVICE_ID", Device_ID_Low_Byte, 0, 16, RO, 0x8400, DEVICE_ID_value_map, "0x1x,"), DEFINE_SETTING_ENTRY("SOFT_RST", Configuration, 0, 1, RW, 0x0000, SOFT_RST_value_map, ""), DEFINE_SETTING_ENTRY("CH_SEL_ADC2", Configuration, 1, 1, RW, 0x0000, CH_SEL_ADC2_value_map, "Miscellaneous Chip Control input select. This bit has no"), DEFINE_SETTING_ENTRY("DUAL_MODE_ADC2", Configuration, 2, 1, RW, 0x0000, DUAL_MODE_ADC2_value_map, "Sets Miscellaneous Chip Control to dual sampling mode"), DEFINE_SETTING_ENTRY("CHIP_ACFG_DIS", Configuration, 4, 1, RW, 0x0000, CHIP_ACFG_DIS_value_map, "Auto-config disable of the following registers:"), DEFINE_SETTING_ENTRY("CH_1__SOURCE", Video_Input_Control, 0, 3, RW, 0x0000, CH_1__SOURCE_value_map, "Selects input pin to CH{1} ADC"), DEFINE_SETTING_ENTRY("CH_2__SOURCE", Video_Input_Control, 4, 2, RW, 0x0000, CH_2__SOURCE_value_map, "Selects input pin to CH{2} ADC"), DEFINE_SETTING_ENTRY("CH_3__SOURCE", Video_Input_Control, 6, 2, RW, 0x0000, CH_3__SOURCE_value_map, "Selects input pin to CH{3} ADC"), DEFINE_SETTING_ENTRY("EN_12DB_CH1", AFE_Control_1, 0, 1, RW, 0x0000, EN_12DB_CH1_value_map, "Enables CH1 extra 12 dB gain"), DEFINE_SETTING_ENTRY("EN_12DB_CH2", AFE_Control_1, 1, 1, RW, 0x0000, EN_12DB_CH2_value_map, "Enables CH2 extra 12 dB gain"), DEFINE_SETTING_ENTRY("EN_12DB_CH3", AFE_Control_1, 2, 1, RW, 0x0000, EN_12DB_CH3_value_map, "Enables CH3 extra 12 dB gain"), DEFINE_SETTING_ENTRY("HALF_BW_CH1", AFE_Control_1, 3, 1, RW, 0x0000, 0, "When set, the CH1 anti-alias filter bandwidth is reduced to half."), DEFINE_SETTING_ENTRY("HALF_BW_CH2", AFE_Control_1, 4, 1, RW, 0x0000, 0, "When set, the CH2 anti-alias filter bandwidth is reduced to half."), DEFINE_SETTING_ENTRY("HALF_BW_CH3", AFE_Control_1, 5, 1, RW, 0x0000, 0, "When set, the CH3 anti-alias filter bandwidth is reduced to half."), DEFINE_SETTING_ENTRY("VGA_SEL_CH1", AFE_Control_1, 6, 1, RW, 0x0000, VGA_SEL_CH1_value_map, "VGA gain select for CH1"), DEFINE_SETTING_ENTRY("VGA_SEL_CH2", AFE_Control_1, 7, 1, RW, 0x0000, VGA_SEL_CH2_value_map, "VGA gain select for CH2"), DEFINE_SETTING_ENTRY("VGA_SEL_CH3", AFE_Control_2, 0, 1, RW, 0x0000, VGA_SEL_CH3_value_map, "VGA gain select for CH3"), DEFINE_SETTING_ENTRY("CLAMP_SEL_CH1", AFE_Control_2, 1, 1, RW, 0x0000, CLAMP_SEL_CH1_value_map, "Clamp level select for CH1"), DEFINE_SETTING_ENTRY("CLAMP_SEL_CH2", AFE_Control_2, 2, 1, RW, 0x0001, CLAMP_SEL_CH2_value_map, "Clamp level select for CH2"), DEFINE_SETTING_ENTRY("CLAMP_SEL_CH3", AFE_Control_2, 3, 1, RW, 0x0001, CLAMP_SEL_CH3_value_map, "Clamp level select for CH3"), DEFINE_SETTING_ENTRY("CHROMA_IN_SEL", AFE_Control_2, 4, 1, RW, 0x0001, CHROMA_IN_SEL_value_map, "ADC input select for chroma input path"), DEFINE_SETTING_ENTRY("LUMA_IN_SEL", AFE_Control_2, 5, 1, RW, 0x0000, LUMA_IN_SEL_value_map, "ADC input select for luma input path"), DEFINE_SETTING_ENTRY("AUD_IN_SEL", AFE_Control_2, 6, 1, RW, 0x0001, AUD_IN_SEL_value_map, "ADC input select for audio input paths:"), DEFINE_SETTING_ENTRY("CLAMP_EN_CH1", AFE_Control_2, 7, 1, RW, 0x0001, CLAMP_EN_CH1_value_map, "Channel 1 clamping"), DEFINE_SETTING_ENTRY("CLAMP_EN_CH2", AFE_Control_3, 0, 1, RW, 0x0000, CLAMP_EN_CH2_value_map, "Enables (powers up) clamping for CH2"), DEFINE_SETTING_ENTRY("CLAMP_EN_CH3", AFE_Control_3, 1, 1, RW, 0x0000, CLAMP_EN_CH3_value_map, "Enables (powers up) clamping for CH3"), DEFINE_SETTING_ENTRY("DROOP_COMP_CH1", AFE_Control_3, 2, 1, RW, 0x0001, 0, "Enables resistance boosting in CH1 input"), DEFINE_SETTING_ENTRY("DROOP_COMP_CH2", AFE_Control_3, 3, 1, RW, 0x0000, 0, "Enables resistance boosting in CH2 input"), DEFINE_SETTING_ENTRY("DROOP_COMP_CH3", AFE_Control_3, 4, 1, RW, 0x0000, 0, "Enables resistance boosting in CH3 input"), DEFINE_SETTING_ENTRY("BYPASS_CH1", AFE_Control_3, 5, 1, RW, 0x0000, 0, "Bypass CH1 anti-alias filter when set."), DEFINE_SETTING_ENTRY("BYPASS_CH2", AFE_Control_3, 6, 1, RW, 0x0000, 0, "Bypass CH2 anti-alias filter when set."), DEFINE_SETTING_ENTRY("BYPASS_CH3", AFE_Control_3, 7, 1, RW, 0x0000, 0, "Bypass CH3 anti-alias filter when set."), DEFINE_SETTING_ENTRY("IREF_SEL", AFE_Control_4, 3, 1, RW, 0x0000, 0, "Selects between on-chip (1) and external (0) resistor to generate"), DEFINE_SETTING_ENTRY("VID_PLL_INT", Video_PLL_Integer, 0, 6, RW, 0x000f, 0, "Video PLL integer coefficient"), DEFINE_SETTING_ENTRY("VID_PLL_POST", Video_PLL_Divider, 0, 6, RW, 0x0004, 0, "Video PLL post divide"), DEFINE_SETTING_ENTRY("AUX_PLL_INT", Aux_PLL_Integer, 0, 6, RW, 0x000a, 0, "Auxiliary PLL integer coefficient"), DEFINE_SETTING_ENTRY("AUX_PLL_POST", Aux_PLL_Divider, 0, 6, RW, 0x0010, 0, "Auxiliary PLL post divide"), DEFINE_SETTING_ENTRY("VID_PLL_FRAC1", Video_PLL_Fractional_1, 0, 8, RW, 0x00fe, 0, "Lowest byte of the 25-bit fractional portion of the PLL multiplier"), DEFINE_SETTING_ENTRY("VID_PLL_FRAC2", Video_PLL_Fractional_2, 0, 8, RW, 0x00e2, 0, "Middle byte of the 25-bit fractional portion of the PLL multiplier"), DEFINE_SETTING_ENTRY("VID_PLL_FRAC3", Video_PLL_Fractional_3, 0, 8, RW, 0x002b, 0, "Highest byte of the 25-bit fractional portion of the PLL multiplier"), DEFINE_SETTING_ENTRY("VID_PLL_FRAC4", Video_PLL_Fractional_4, 0, 1, RW, 0x0000, 0, "Highest bit of the 25-bit fractional portion of the PLL multiplier"), DEFINE_SETTING_ENTRY("AUX_PLL_FRAC1", Aux_PLL_Fractional_1, 0, 8, RW, 0x0009, 0, "Lowest byte of the 25-bit fractional portion of the PLL multiplier"), DEFINE_SETTING_ENTRY("AUX_PLL_FRAC2", Aux_PLL_Fractional_2, 0, 8, RW, 0x00d7, 0, "Middle byte of the 25-bit fractional portion of the PLL multiplier"), DEFINE_SETTING_ENTRY("AUX_PLL_FRAC3", Aux_PLL_Fractional_3, 0, 8, RW, 0x0098, 0, "Highest byte of the 25-bit fractional portion of the PLL multiplier"), DEFINE_SETTING_ENTRY("AUX_PLL_FRAC4", Aux_PLL_Fractional_4, 0, 1, RW, 0x0000, 0, "Highest bit of the 25-bit fractional portion of the PLL multiplier"), DEFINE_SETTING_ENTRY("GPIO0_OUT_EN", Pin_Control_1, 0, 1, RW, 0x0000, GPIO0_OUT_EN_value_map, "Output enable control for GPIO0 pin (2584x only)"), DEFINE_SETTING_ENTRY("GPIO1_OUT_EN", Pin_Control_1, 1, 1, RW, 0x0000, GPIO1_OUT_EN_value_map, "Output enable control for GPIO1 pin (2584x only)"), DEFINE_SETTING_ENTRY("CHIP_SEL_VIPCLK_OUT_EN", Pin_Control_1, 2, 1, RW, 0x0000, CHIP_SEL_VIPCLK_OUT_EN_value_map, "Output enable for CHIP_SEL/VIPCLK_OUT pin"), DEFINE_SETTING_ENTRY("IRQN_OUT_EN", Pin_Control_1, 3, 1, RW, 0x0000, IRQN_OUT_EN_value_map, "Output enable for IRQN_OUT pin"), DEFINE_SETTING_ENTRY("IR_RX_OUT_EN", Pin_Control_1, 4, 1, RW, 0x0000, IR_RX_OUT_EN_value_map, "Output enable for IR_RX_OUT pin"), DEFINE_SETTING_ENTRY("IR_TX_OUT_EN", Pin_Control_1, 5, 1, RW, 0x0000, IR_TX_OUT_EN_value_map, "Output enable for IR_TX_OUT pin"), DEFINE_SETTING_ENTRY("DVALID_OUT_EN", Pin_Control_1, 6, 1, RW, 0x0000, DVALID_OUT_EN_value_map, "Output enable for DVALID/PRGM0 pin"), DEFINE_SETTING_ENTRY("FIELD_OUT_EN", Pin_Control_1, 7, 1, RW, 0x0000, FIELD_OUT_EN_value_map, "Output enable for FIELD/PRGM1 pin"), DEFINE_SETTING_ENTRY("HRESET_OUT_EN", Pin_Control_2, 0, 1, RW, 0x0000, HRESET_OUT_EN_value_map, "Output enable for HRESET/PRGM2 pin"), DEFINE_SETTING_ENTRY("VRESET_OUT_EN", Pin_Control_2, 1, 1, RW, 0x0000, VRESET_OUT_EN_value_map, "Output enable for VRESET/HCTL/PRGM3 pin"), DEFINE_SETTING_ENTRY("VID_OUT_EN", Pin_Control_2, 2, 1, RW, 0x0000, VID_OUT_EN_value_map, "Output enable for VID_DATA [7:0] pin"), DEFINE_SETTING_ENTRY("PIXCLK_OUT_EN", Pin_Control_2, 3, 1, RW, 0x0000, PIXCLK_OUT_EN_value_map, "Output enable for PIXCLK pin"), DEFINE_SETTING_ENTRY("SA_SDIN_OUT_EN", Pin_Control_2, 4, 1, RW, 0x0000, SA_SDIN_OUT_EN_value_map, "Output enable for SA_SDIN pin"), DEFINE_SETTING_ENTRY("SA_BCLKIN_OUT_EN", Pin_Control_2, 5, 1, RW, 0x0000, SA_BCLKIN_OUT_EN_value_map, "Output enable for SA_WCLKIN pin"), DEFINE_SETTING_ENTRY("SA_WCLKIN_OUT_EN", Pin_Control_2, 6, 1, RW, 0x0000, SA_WCLKIN_OUT_EN_value_map, "Output enable for SA_WCLKIN pin"), DEFINE_SETTING_ENTRY("SA_SDOUT_OUT_EN", Pin_Control_2, 7, 1, RW, 0x0000, SA_SDOUT_OUT_EN_value_map, "Output enable for SA_SDOUT pin"), DEFINE_SETTING_ENTRY("SA_BCLKOUT_OUT_EN", Pin_Control_3, 0, 1, RW, 0x0000, SA_BCLKOUT_OUT_EN_value_map, "Output enable for SA_BCLKOUT pin (2584X only)."), DEFINE_SETTING_ENTRY("SA_WCLKOUT_OUT_EN", Pin_Control_3, 1, 1, RW, 0x0000, SA_WCLKOUT_OUT_EN_value_map, "Output enable for SA_WCLKOUT pin (2584X only)."), DEFINE_SETTING_ENTRY("PLL_CLK_OUT_EN", Pin_Control_3, 2, 1, RW, 0x0000, PLL_CLK_OUT_EN_value_map, "Output enable for PLL_CLK/PRGM7 pin"), DEFINE_SETTING_ENTRY("AC_OUT_OUT_EN", Pin_Control_3, 3, 1, RW, 0x0000, AC_OUT_OUT_EN_value_map, "Output enable control for AC_SDOUT, ADC_SYNC, and"), DEFINE_SETTING_ENTRY("AC_IN_OUT_EN", Pin_Control_3, 4, 1, RW, 0x0000, AC_IN_OUT_EN_value_map, "Output enable control for AC_SDIN and AC_BITCLK pads"), DEFINE_SETTING_ENTRY("IRQ_N_PRGM4", Pin_Control_4, 1, 1, RW, 0x0000, IRQ_N_PRGM4_value_map, "_POLAR Polarity of IRQ_N/PRGM4 output"), DEFINE_SETTING_ENTRY("VID_IRQ_STAT", Pin_Control_4, 2, 1, RO, 0x0000, VID_IRQ_STAT_value_map, "Video Interrupt status"), DEFINE_SETTING_ENTRY("IR_IRQ_STAT", Pin_Control_4, 4, 1, RO, 0x0000, IR_IRQ_STAT_value_map, "Infrared Remote Interrupt status"), DEFINE_SETTING_ENTRY("VID_OUT_SPD", Pin_Control_5, 0, 2, RW, 0x0000, VID_OUT_SPD_value_map, "Controls drive strength of PIXCLK and VID_DATA pads."), DEFINE_SETTING_ENTRY("VID_CTRL_SPD", Pin_Control_5, 2, 2, RW, 0x0000, VID_CTRL_SPD_value_map, "Controls drive strength of PRGM{0:2} pads."), DEFINE_SETTING_ENTRY("AC_OUT_SPD", Pin_Control_5, 4, 2, RW, 0x0000, AC_OUT_SPD_value_map, "Controls drive strength of AC_SYNC, AC_RST_N, AC_BITCLK,"), DEFINE_SETTING_ENTRY("SA_OUT_SPD", Pin_Control_5, 6, 2, RW, 0x0000, SA_OUT_SPD_value_map, "Controls drive strength of SA_SDOUT, SA_WCLK_OUT, and"), DEFINE_SETTING_ENTRY("GEN_OUT_SPD", Pin_Control_6, 0, 2, RW, 0x0000, GEN_OUT_SPD_value_map, "Controls drive strength of IR_TX/PRGM6, IR_RX/PRGM5,"), DEFINE_SETTING_ENTRY("GPIO0_OUT_SEL", Pin_Configuration_1, 0, 4, RW, 0x0000, GPIO0_OUT_SEL_value_map, "Selects which internal state is output on the GPIO[0]/PRGM8 pin."), DEFINE_SETTING_ENTRY("GPIO1_OUT_SEL", Pin_Configuration_1, 4, 4, RW, 0x0000, GPIO1_OUT_SEL_value_map, "Selects which internal state is output on the GPIO[1]/PRGM9 pin."), DEFINE_SETTING_ENTRY("CHIPSEL_OUT_SEL", Pin_Configuration_2, 0, 4, RW, 0x0000, CHIPSEL_OUT_SEL_value_map, "Selects which internal state is output on the CHIP_SEL/"), DEFINE_SETTING_ENTRY("IRQN_OUT_SEL", Pin_Configuration_2, 4, 4, RW, 0x0000, IRQN_OUT_SEL_value_map, "Selects which signal to output on the IRQ_N/PRGM4 pin."), DEFINE_SETTING_ENTRY("IR_RX_OUT_SEL", Pin_Configuration_3, 0, 4, RW, 0x0000, IR_RX_OUT_SEL_value_map, "Selects which signal to output on the IR_RX/PRGM5 pin if this"), DEFINE_SETTING_ENTRY("IR_TX_OUT_SEL", Pin_Configuration_3, 4, 4, RW, 0x0000, IR_TX_OUT_SEL_value_map, "Selects which signal to output on the IR_TX/PRGM6 pin."), DEFINE_SETTING_ENTRY("DVALID_PRGM0_OUT_SEL", Pin_Configuration_4, 0, 4, RW, 0x0000, DVALID_PRGM0_OUT_SEL_value_map, "Selects which signal to output on the PRGM0 pin."), DEFINE_SETTING_ENTRY("FIELD_PRGM1_OUT_SEL", Pin_Configuration_4, 4, 4, RW, 0x0000, FIELD_PRGM1_OUT_SEL_value_map, "Selects which signal to output on the PRGM1 pin."), DEFINE_SETTING_ENTRY("HRESET_PRGM2_OUT_SEL", Pin_Configuration_5, 0, 4, RW, 0x0000, HRESET_PRGM2_OUT_SEL_value_map, "Selects which signal to output on the PRGM2 pin."), DEFINE_SETTING_ENTRY("VRESET_HCTL_PRGM3_OUT_SEL", Pin_Configuration_5, 4, 4, RW, 0x0000, VRESET_HCTL_PRGM3_OUT_SEL_value_map, "Selects which signal to output on the PRGM3 pin."), DEFINE_SETTING_ENTRY("VID_DATA_OUT_SEL", Pin_Configuration_6, 0, 1, RW, 0x0000, 0, "Should only be written with a 0"), DEFINE_SETTING_ENTRY("PIXCLK_OUT_SEL", Pin_Configuration_6, 1, 1, RW, 0x0000, 0, "Should only be written with a 0"), DEFINE_SETTING_ENTRY("AC_OUT_SEL", Pin_Configuration_6, 2, 1, RW, 0x0000, AC_OUT_SEL_value_map, "Selects which data is output on AC†¢97 output pins of AC_RSTN,"), DEFINE_SETTING_ENTRY("SA_OUT_OUT_SEL", Pin_Configuration_6, 4, 2, RW, 0x0000, SA_OUT_OUT_SEL_value_map, "Selects which data is output on the SA_WCLK_IN SA_BCLK_IN, and"), DEFINE_SETTING_ENTRY("SA_IN_OUT_SEL", Pin_Configuration_6, 6, 2, RW, 0x0000, SA_IN_OUT_SEL_value_map, "Selects which data is output on the SA_WCLK_OUT, SA_BCLK_OUT,"), DEFINE_SETTING_ENTRY("AUX_PLL_AOUT_SEL", Pin_Configuration_7, 0, 3, RW, 0x0001, AUX_PLL_AOUT_SEL_value_map, "Selects which signal to output on the PLL_CLK/PRGM7 pin when AUX"), DEFINE_SETTING_ENTRY("AUX_PLL_DOUT_SEL", Pin_Configuration_7, 4, 4, RW, 0x0000, AUX_PLL_DOUT_SEL_value_map, "Selects which signal to output on the PLL _CLK pin."), DEFINE_SETTING_ENTRY("AC_BITCLK_IN_SEL", Pin_Configuration_8, 0, 4, RW, 0x0000, AC_BITCLK_IN_SEL_value_map, "Selects the pin that is muxed to the AC_BITCLK input of the"), DEFINE_SETTING_ENTRY("AC_SDIN_IN_SEL", Pin_Configuration_8, 4, 4, RW, 0x0001, AC_SDIN_IN_SEL_value_map, "Selects the pin that is muxed to the AC_/sdin input of the"), DEFINE_SETTING_ENTRY("GPI0_IN_SEL", Pin_Configuration_9, 0, 4, RW, 0x0049, GPI0_IN_SEL_value_map, "Selects the pin that is muxed to the internal GPI0 flop."), DEFINE_SETTING_ENTRY("GPI1_IN_SEL", Pin_Configuration_9, 4, 4, RW, 0x03e8, GPI1_IN_SEL_value_map, "Selects the pin that is muxed to the internal GPI1 flop."), DEFINE_SETTING_ENTRY("GPI2_IN_SEL", Pin_Configuration_10, 0, 4, RW, 0x0048, GPI2_IN_SEL_value_map, "Selects the pin that is muxed to the internal GPI2 flop."), DEFINE_SETTING_ENTRY("GPI3_IN_SEL", Pin_Configuration_10, 4, 4, RW, 0x03f3, GPI3_IN_SEL_value_map, "Selects the pin that is muxed to the internal GPI3 flop."), DEFINE_SETTING_ENTRY("GPO_OUT", Pin_Configuration_11, 0, 4, RW, 0x0000, 0, "Registers that hold data that may get sent to the pins selected by"), DEFINE_SETTING_ENTRY("GPI_IN", Pin_Configuration_11, 4, 4, RO, 0x0000, 0, "Data from pins selected by the GPIOx_IN_SEL register settings."), DEFINE_SETTING_ENTRY("SA_MCLK_DIV", Pin_Configuration_12, 0, 6, RW, 0x0000, 0, "Controls the generation of alternate serial audio master clock"), DEFINE_SETTING_ENTRY("SA_MCLK_SEL", Pin_Configuration_12, 6, 1, RW, 0x0000, SA_MCLK_SEL_value_map, "Selects alternate post-divider for internal SA_MCLK. The serial"), DEFINE_SETTING_ENTRY("VID_COUNT", Video_Count_Low, 0, 24, RW, 0x1193f8, 0, "Least significant byte of the expected count (minus 1 and times"), DEFINE_SETTING_ENTRY("EN_AV_LOCK", Audio_Lock, 0, 1, RW, 0x0000, 0, "Enable locking of auxiliary PLL to video pixel rate."), DEFINE_SETTING_ENTRY("AUD_LOCK_KD_SHIFT", Audio_Lock, 4, 2, RW, 0x000a, 0, "The gain applied to the direct error path of the loop filter through"), DEFINE_SETTING_ENTRY("AUD_LOCK_KI_SHIFT", Audio_Lock, 6, 2, RW, 0x000a, 0, "The gain applied to the indirect error path of the loop filter"), DEFINE_SETTING_ENTRY("AUD_COUNT", Audio_Count_Low, 0, 20, RW, 0x005fff, 0, "Least significant byte of the number of audio sample-rate clocks,"), DEFINE_SETTING_ENTRY("AUD_LOCK_FREQ_SHIFT", Audio_Lock_2, 4, 2, RW, 0x0000, 0, "The gain applied to the frequency error (difference in actual vs."), DEFINE_SETTING_ENTRY("AUD_LOCK_KD_MULT", Audio_Lock_3, 0, 4, RW, 0x0001, 0, ""), DEFINE_SETTING_ENTRY("AUD_LOCK_KI_MULT", Audio_Lock_3, 4, 4, RW, 0x0001, 0, "The gain applied to the indirect error path of the loop filter"), DEFINE_SETTING_ENTRY("PWR_DN_TUNING", Power_Control_1, 0, 1, RW, 0x0000, PWR_DN_TUNING_value_map, "Powers down filter tuning circuitry."), DEFINE_SETTING_ENTRY("PWR_DN_DLL1", Power_Control_1, 1, 1, RW, 0x0000, PWR_DN_DLL1_value_map, "Powers down DLL1 (5x clock) circuitry."), DEFINE_SETTING_ENTRY("PWR_DN_DLL2", Power_Control_1, 2, 1, RW, 0x0000, PWR_DN_DLL2_value_map, "Powers down DLL2 (5x clock) circuitry."), DEFINE_SETTING_ENTRY("PWR_DN_ADC1", Power_Control_1, 3, 1, RW, 0x0000, PWR_DN_ADC1_value_map, "Powers down ADC1 circuitry."), DEFINE_SETTING_ENTRY("PWR_DN_ADC2", Power_Control_1, 4, 1, RW, 0x0000, PWR_DN_ADC2_value_map, "Powers down Miscellaneous Chip Control circuitry."), DEFINE_SETTING_ENTRY("PWR_DN_CH1", Power_Control_1, 5, 1, RW, 0x0000, PWR_DN_CH1_value_map, "Powers down Channel 1 VGA/filter circuitry."), DEFINE_SETTING_ENTRY("PWR_DN_CH2", Power_Control_1, 6, 1, RW, 0x0000, PWR_DN_CH2_value_map, "Powers down Channel 2 VGA/filter circuitry."), DEFINE_SETTING_ENTRY("PWR_DN_CH3", Power_Control_1, 7, 1, RW, 0x0000, PWR_DN_CH3_value_map, "Powers down Channel 3 VGA/filter circuitry."), DEFINE_SETTING_ENTRY("SLEEP_ANALOG_MSK", Power_Control_2, 0, 1, RW, 0x0000, SLEEP_ANALOG_MSK_value_map, "Analog subsystem sleep mask"), DEFINE_SETTING_ENTRY("SLEEP_DLL_MSK", Power_Control_2, 1, 1, RW, 0x0000, SLEEP_DLL_MSK_value_map, "DLL sleep mask"), DEFINE_SETTING_ENTRY("SLEEP_PLL_MSK", Power_Control_2, 2, 1, RW, 0x0000, SLEEP_PLL_MSK_value_map, "PLL sleep mask"), DEFINE_SETTING_ENTRY("VCLK_GATE_MSK", Power_Control_2, 3, 1, RW, 0x0000, VCLK_GATE_MSK_value_map, "Video clock gate mask"), DEFINE_SETTING_ENTRY("CLK5x_GATE_MSK", Power_Control_2, 4, 1, RW, 0x0000, CLK5x_GATE_MSK_value_map, "CLK5x gate mask"), DEFINE_SETTING_ENTRY("SCLK_GATE_MSK", Power_Control_2, 5, 1, RW, 0x0000, SCLK_GATE_MSK_value_map, "SCLK and SA_MCLK gate mask"), DEFINE_SETTING_ENTRY("FOUR_X_CLK_ADC", AFE_Diagnostic_Control_1, 0, 1, RW, 0x0000, FOUR_X_CLK_ADC_value_map, "Chooses 4x or 5x DLL output"), DEFINE_SETTING_ENTRY("VREG_D_1_0_", AFE_Diagnostic_Control_1, 1, 2, RW, 0x0001, VREG_D_1_0__value_map, "Voltage Regulator Select. Controls what voltage the regulator"), DEFINE_SETTING_ENTRY("VREF_CTRL_ADC", AFE_Diagnostic_Control_1, 3, 1, RW, 0x0000, VREF_CTRL_ADC_value_map, "Digital control for ADC reference voltage."), DEFINE_SETTING_ENTRY("BIAS_CTRL_ADC_1_0_", AFE_Diagnostic_Control_2, 0, 2, RW, 0x0000, BIAS_CTRL_ADC_1_0__value_map, "Digital control for ADC bias current."), DEFINE_SETTING_ENTRY("BIAS_CTRL_ADC_2_", AFE_Diagnostic_Control_2, 2, 1, RW, 0x0000, BIAS_CTRL_ADC_2__value_map, "Digital control for refp and refm"), DEFINE_SETTING_ENTRY("BIAS_CTRL_ADC_4_3_", AFE_Diagnostic_Control_2, 3, 2, RW, 0x000b, BIAS_CTRL_ADC_4_3__value_map, "MSB comparator current."), DEFINE_SETTING_ENTRY("BIAS_CTRL_ADC_6_5_", AFE_Diagnostic_Control_2, 5, 2, RW, 0x0000, BIAS_CTRL_ADC_6_5__value_map, "Digital control for the reference buffer bias."), DEFINE_SETTING_ENTRY("S2DIFF_BIAS_1_0_", AFE_Diagnostic_Control_3, 0, 2, RW, 0x0001, S2DIFF_BIAS_1_0__value_map, "Digital control for the single-ended to differential converter bias"), DEFINE_SETTING_ENTRY("FILTER_BIAS_1_0_", AFE_Diagnostic_Control_3, 2, 2, RW, 0x0001, FILTER_BIAS_1_0__value_map, "Digital control for bias current multiplier."), DEFINE_SETTING_ENTRY("TUNE_FIL_RST", AFE_Diagnostic_Control_5, 0, 1, RW, 0x0000, 0, "Reset filter tuning logic. When 1, filter tuning is reset. When set"), DEFINE_SETTING_ENTRY("CH_SEL_ADC1", AFE_Diagnostic_Control_5, 1, 1, RW, 0x0000, CH_SEL_ADC1_value_map, "ADC1 test mode"), DEFINE_SETTING_ENTRY("DISCONNECT_CH1", AFE_Diagnostic_Control_5, 2, 1, RW, 0x0000, DISCONNECT_CH1_value_map, "Disables the filter in CH1 test mode."), DEFINE_SETTING_ENTRY("TEST_MODE_CH1", AFE_Diagnostic_Control_5, 3, 1, RW, 0x0000, TEST_MODE_CH1_value_map, "Connects the differential analog signal at ADC1 input to pins"), DEFINE_SETTING_ENTRY("TUNE_IN_4_0_", AFE_Diagnostic_Control_6, 0, 5, RW, 0x0000, 0, "Tuning code to be used when FORCE_TUNING is set. Overrides"), DEFINE_SETTING_ENTRY("FORCE_TUNING", AFE_Diagnostic_Control_6, 7, 1, RW, 0x0000, FORCE_TUNING_value_map, "Auto tuning code override"), DEFINE_SETTING_ENTRY("TUNE_OUT", AFE_Diagnostic_Control_7, 0, 5, RO, 0x0000, 0, "The tuning code selected by the auto-tune algorithm."), DEFINE_SETTING_ENTRY("TUNING_READY", AFE_Diagnostic_Control_7, 5, 1, RO, 0x0000, TUNING_READY_value_map, "Filter auto tuning status"), DEFINE_SETTING_ENTRY("VID_DUAL_FLAG_POL", AFE_Diagnostic_Control_8, 0, 1, RW, 0x0000, VID_DUAL_FLAG_POL_value_map, "Video Decoder Dual Flag Polarity"), DEFINE_SETTING_ENTRY("AUD_DUAL_FLAG_POL", AFE_Diagnostic_Control_8, 1, 1, RW, 0x0000, AUD_DUAL_FLAG_POL_value_map, "Audio Decoder Dual Flag Polarity"), DEFINE_SETTING_ENTRY("PLL_SPMP", PLL_Diagnostic_Control_1, 0, 6, RW, 0x0004, 0, "PLL charge pump current"), DEFINE_SETTING_ENTRY("VID_PLL_DDS", PLL_Diagnostic_Control_2, 0, 1, RW, 0x0000, VID_PLL_DDS_value_map, "Video PLL delta signal fractional divide"), DEFINE_SETTING_ENTRY("AUX_PLL_DDS", PLL_Diagnostic_Control_2, 1, 1, RW, 0x0000, AUX_PLL_DDS_value_map, "Auxiliary PLL delta sigma fractional divide"), DEFINE_SETTING_ENTRY("VID_PLL_RST", PLL_Diagnostic_Control_2, 2, 1, RW, 0x0000, VID_PLL_RST_value_map, "Auxiliary PLL reset"), DEFINE_SETTING_ENTRY("AUX_PLL_RST", PLL_Diagnostic_Control_2, 3, 1, RW, 0x0000, AUX_PLL_RST_value_map, "Video PLL reset"), DEFINE_SETTING_ENTRY("AUX_PLL_LOCK", PLL_Diagnostic_Control_2, 4, 1, RO, 0x0000, AUX_PLL_LOCK_value_map, "Auxiliary PLL lock status"), DEFINE_SETTING_ENTRY("VID_PLL_LOCK", PLL_Diagnostic_Control_2, 5, 1, RO, 0x0000, VID_PLL_LOCK_value_map, "Video PLL lock status"), DEFINE_SETTING_ENTRY("AUX_PLL_UNLOCK", PLL_Diagnostic_Control_2, 6, 1, RR, 0x0000, AUX_PLL_UNLOCK_value_map, "Auxiliary PLL unlock detection"), DEFINE_SETTING_ENTRY("VID_PLL_UNLOCK", PLL_Diagnostic_Control_2, 7, 1, RR, 0x0000, VID_PLL_UNLOCK_value_map, "Video PLL unlock detection"), DEFINE_SETTING_ENTRY("DLL1_FLD", DLL1_Diagnostic_Control_2, 0, 1, RW, 0x0001, 0, "False Lock Detect mode"), DEFINE_SETTING_ENTRY("DLL1_UP_OVRD", DLL1_Diagnostic_Control_2, 1, 1, RW, 0x0000, 0, "Overrides the up command to PFD."), DEFINE_SETTING_ENTRY("DLL1_DOWN_OVRD", DLL1_Diagnostic_Control_2, 2, 1, RW, 0x0000, 0, "Overrides the down command to PFD."), DEFINE_SETTING_ENTRY("DLL1_CHPREF", DLL1_Diagnostic_Control_2, 3, 3, RW, 0x0064, 0, "Charge pump current."), DEFINE_SETTING_ENTRY("DLL1_COMP_GT", DLL1_Diagnostic_Control_2, 6, 3, RW, 0x0004, 0, "Lower 2 bits of COMP_GT"), DEFINE_SETTING_ENTRY("DLL1_COMP_LT", DLL1_Diagnostic_Control_3, 1, 3, RW, 0x0009, 0, "Used in False Lock Detect: counts this many pulses in half period"), DEFINE_SETTING_ENTRY("DLL1_DEPTH", DLL1_Diagnostic_Control_3, 4, 3, RW, 0x006e, 0, "Used in False Lock detect: increases stability of decisions in FLD."), DEFINE_SETTING_ENTRY("DLL1_DLYS", DLL1_Diagnostic_Control_3, 7, 2, RW, 0x0001, 0, "Low bit of DLYS"), DEFINE_SETTING_ENTRY("DLL1_CURRSET", DLL1_Diagnostic_Control_4, 1, 4, RW, 0x0000, 0, "Changes current used in DLL."), DEFINE_SETTING_ENTRY("DLL1_BYPASS", DLL1_Diagnostic_Control_4, 7, 1, RW, 0x0000, 0, "Clock reference for DLL1 (ADC DLL) input from clock pad rather"), DEFINE_SETTING_ENTRY("DLL2_Diagnostic_Control_1_REG", DLL2_Diagnostic_Control_1, 0, 8, RW, 0x0000, 0, "Missing bit spec for reg"), DEFINE_SETTING_ENTRY("DLL2_FLD", DLL2_Diagnostic_Control_2, 0, 1, RW, 0x0001, 0, "False Lock Detect mode."), DEFINE_SETTING_ENTRY("DLL2_UP_OVRD", DLL2_Diagnostic_Control_2, 1, 1, RW, 0x0000, 0, "Overrides the up command to PFD."), DEFINE_SETTING_ENTRY("DLL2_DOWN_OVRD", DLL2_Diagnostic_Control_2, 2, 1, RW, 0x0000, 0, "Overrides the down command to PFD."), DEFINE_SETTING_ENTRY("DLL2_CHPREF", DLL2_Diagnostic_Control_2, 3, 3, RW, 0x0064, 0, "Charge pump current."), DEFINE_SETTING_ENTRY("DLL2_COMP_GT", DLL2_Diagnostic_Control_2, 6, 3, RW, 0x0004, 0, "Used in False Lock Detect: counts this many pulses in half period"), DEFINE_SETTING_ENTRY("DLL2_COMP_LT", DLL2_Diagnostic_Control_3, 1, 3, RW, 0x0009, 0, "Used in False Lock Detect: counts this many pulses in half period"), DEFINE_SETTING_ENTRY("DLL2_DEPTH", DLL2_Diagnostic_Control_3, 4, 3, RW, 0x006e, 0, "Used in False Lock detect: increases stability of decisions in FLD."), DEFINE_SETTING_ENTRY("DLL2_DLYS", DLL2_Diagnostic_Control_3, 7, 2, RW, 0x0001, 0, "Low bit of DLYS"), DEFINE_SETTING_ENTRY("DLL2_CURRSET", DLL2_Diagnostic_Control_4, 1, 4, RW, 0x0000, 0, "Changes current used in DLL"), DEFINE_SETTING_ENTRY("DLL2_BYPASS", DLL2_Diagnostic_Control_4, 6, 2, RW, 0x0000, 0, "Clock reference for DLL2 (Audio Decoder DLL) input from clock"), DEFINE_SETTING_ENTRY("WIN", IR_Control_1, 0, 2, RW, 0x0000, WIN_value_map, "Next Predicted Receive Carrier Edge Window Limits"), DEFINE_SETTING_ENTRY("EDG", IR_Control_1, 2, 2, RW, 0x0000, EDG_value_map, "Receive Edge Detect Control"), DEFINE_SETTING_ENTRY("DMD", IR_Control_1, 4, 1, RW, 0x0000, DMD_value_map, "Receive Demodulation Enable"), DEFINE_SETTING_ENTRY("MOD", IR_Control_1, 5, 1, RW, 0x0000, MOD_value_map, "Transmit Modulation Enable"), DEFINE_SETTING_ENTRY("RFE", IR_Control_1, 6, 1, RW, 0x0000, RFE_value_map, "Receive FIFO Enable"), DEFINE_SETTING_ENTRY("TFE", IR_Control_1, 7, 1, RW, 0x0000, TFE_value_map, "Transmit FIFO Enable"), DEFINE_SETTING_ENTRY("RXE", IR_Control_2, 0, 1, RW, 0x0000, RXE_value_map, "Receiver Enable"), DEFINE_SETTING_ENTRY("TXE", IR_Control_2, 1, 1, RW, 0x0000, TXE_value_map, "Transmitter Enable"), DEFINE_SETTING_ENTRY("RIC", IR_Control_2, 2, 1, RW, 0x0000, RIC_value_map, "Receiver Interrupt Control"), DEFINE_SETTING_ENTRY("TIC", IR_Control_2, 3, 1, RW, 0x0000, TIC_value_map, "Transmitter Interrupt Control"), DEFINE_SETTING_ENTRY("CPL", IR_Control_2, 4, 1, RW, 0x0000, CPL_value_map, "Carrier Polarity (Transmitter Only)"), DEFINE_SETTING_ENTRY("LBM", IR_Control_2, 5, 1, RW, 0x0000, LBM_value_map, "Loop Back Mode"), DEFINE_SETTING_ENTRY("R", IR_Control_2, 6, 1, RW, 0x0000, R_value_map, "Receive FIFO load on Timer Overflow Disable"), DEFINE_SETTING_ENTRY("TCD", IR_TX_Clock_Divider_Low, 0, 16, RW, 0xffff, 0, "Transmit Clock Divider"), DEFINE_SETTING_ENTRY("RCD", IR_RX_Clock_Divider_Low, 0, 16, RW, 0xffff, 0, "Receive Clock Divider"), DEFINE_SETTING_ENTRY("CDC", IR_TX_Carrier_Duty_Cycle, 0, 4, RW, 0x0000, CDC_value_map, "Transmit Carrier Duty Cycle"), DEFINE_SETTING_ENTRY("RTO", IR_Status, 0, 1, RO, 0x0000, RTO_value_map, "Receive Pulse Width Timer Time-out"), DEFINE_SETTING_ENTRY("ROR", IR_Status, 1, 1, RO, 0x0000, ROR_value_map, "Receive FIFO Overrun"), DEFINE_SETTING_ENTRY("TBY", IR_Status, 3, 1, RO, 0x0000, TBY_value_map, "Transmitter Busy (noninterruptible)"), DEFINE_SETTING_ENTRY("RSR", IR_Status, 4, 1, RO, 0x0000, RSR_value_map, "Receive FIFO Service Request"), DEFINE_SETTING_ENTRY("TSR", IR_Status, 5, 1, RO, 0x0000, TSR_value_map, "Transmit FIFO Service Request"), DEFINE_SETTING_ENTRY("ROE", IR_Interrupt_Enable, 1, 1, RW, 0x0000, ROE_value_map, "Receive FIFO Overrun Interrupt Enable"), DEFINE_SETTING_ENTRY("RSE", IR_Interrupt_Enable, 4, 1, RW, 0x0000, RSE_value_map, "Receive FIFO Service Request Interrupt Enable"), DEFINE_SETTING_ENTRY("TSE", IR_Interrupt_Enable, 5, 1, RW, 0x0000, TSE_value_map, "Transmit FIFO Service Request Interrupt Enable"), DEFINE_SETTING_ENTRY("LPF", IR_Low_Pass_Filter_Low, 0, 16, RW, 0x0000, 0, "Low-Pass Filter Modulus"), DEFINE_SETTING_ENTRY("RX_TX_FIFO", IR_FIFO_Low, 0, 16, RW, 0x0000, 0, "Transmit/Receive"), DEFINE_SETTING_ENTRY("RX_TX_LVL", IR_FIFO_Level, 0, 1, RW, 0x0000, 0, "Transmit/Receive Pin Level"), DEFINE_SETTING_ENTRY("RXNDV", IR_FIFO_Level, 1, 1, RO, 0x0000, RXNDV_value_map, "Receive Next Data Valid (read only)"), DEFINE_SETTING_ENTRY("VID_FMT_SEL", Video_Mode_Control_1, 0, 4, RW, 0x0000, VID_FMT_SEL_value_map, "Manual video format select value. This value is used to force the"), DEFINE_SETTING_ENTRY("SQ_PIXEL", Video_Mode_Control_1, 4, 1, RW, 0x0000, 0, "Square-pixel mode"), DEFINE_SETTING_ENTRY("ACFG_DIS", Video_Mode_Control_1, 5, 1, RW, 0x0000, ACFG_DIS_value_map, "Disable autoconfig of registers addressed 0x470 to 0x47F based"), DEFINE_SETTING_ENTRY("AFD_PAL_SEL", Video_Mode_Control_1, 6, 1, RW, 0x0000, AFD_PAL_SEL_value_map, "This bit is used by the Auto Format Detect block to differentiate"), DEFINE_SETTING_ENTRY("AFD_NTSC_SEL", Video_Mode_Control_1, 7, 1, RW, 0x0000, AFD_NTSC_SEL_value_map, "This bit is used by the Auto Format Detect block to differentiate"), DEFINE_SETTING_ENTRY("AFD_ACQUIRE", Video_Mode_Control_2, 0, 1, RW, 0x0000, AFD_ACQUIRE_value_map, "By setting to 1 and then 0, forces the auto-format-detect state"), DEFINE_SETTING_ENTRY("INPUT_MODE", Video_Mode_Control_2, 1, 2, RW, 0x0000, INPUT_MODE_value_map, "Signal Input Format"), DEFINE_SETTING_ENTRY("MAN_SC_FAST_LOCK", Video_Mode_Control_2, 3, 1, RW, 0x0000, MAN_SC_FAST_LOCK_value_map, "Manual chroma subcarrier lock speed select."), DEFINE_SETTING_ENTRY("AUTO_SC_LOCK", Video_Mode_Control_2, 4, 1, RW, 0x0001, AUTO_SC_LOCK_value_map, "Auto chroma subcarrier lock speed select"), DEFINE_SETTING_ENTRY("CKILLEN", Video_Mode_Control_2, 5, 1, RW, 0x0001, CKILLEN_value_map, "Chroma killer enable"), DEFINE_SETTING_ENTRY("CAGCEN", Video_Mode_Control_2, 6, 1, RW, 0x0001, CAGCEN_value_map, "Chroma AGC enable"), DEFINE_SETTING_ENTRY("WCEN", Video_Mode_Control_2, 7, 1, RW, 0x0001, 0, "White crush enable"), DEFINE_SETTING_ENTRY("FAST_LOCK_MD", Video_Mode_Control_3, 0, 1, RW, 0x0000, 0, "Active-high fast lock algorithm select. This register selects"), DEFINE_SETTING_ENTRY("CLR_LOCK_STAT", Video_Mode_Control_3, 1, 1, SC, 0x0000, 0, "Clear HLOCK, VLOCK, and clock status bits"), DEFINE_SETTING_ENTRY("COMB_NOTCH_MODE", Video_Mode_Control_3, 2, 2, RW, 0x000a, COMB_NOTCH_MODE_value_map, "Controls behavior Y/C separation when adaptive comb filter"), DEFINE_SETTING_ENTRY("CKILL_MODE", Video_Mode_Control_3, 4, 2, RW, 0x0000, CKILL_MODE_value_map, "Color Kill Mode. Defines how luma output is generated when"), DEFINE_SETTING_ENTRY("AFD_PALM_SEL", Video_Mode_Control_4, 0, 2, RW, 0x0000, AFD_PALM_SEL_value_map, "Select PAL-M format when 525-lines and 3.58 carrier is"), DEFINE_SETTING_ENTRY("AFD_FORCE_PAL", Video_Mode_Control_4, 2, 1, RW, 0x0000, AFD_FORCE_PAL_value_map, "Force PAL_BG format when 625 lines are detected."), DEFINE_SETTING_ENTRY("AFD_FORCE_PALNC", Video_Mode_Control_4, 3, 1, RW, 0x0000, AFD_FORCE_PALNC_value_map, "Force PAL_Nc format when 625 lines are detected."), DEFINE_SETTING_ENTRY("AFD_FORCE_SECAM", Video_Mode_Control_4, 4, 1, RW, 0x0000, AFD_FORCE_SECAM_value_map, "Force SECAM format when 625 lines are detected."), DEFINE_SETTING_ENTRY("AFD_PAL60_DIS", Video_Mode_Control_4, 5, 1, RW, 0x0000, AFD_PAL60_DIS_value_map, "Disable the auto detection of PAL-60 formats."), DEFINE_SETTING_ENTRY("OUT_MODE", Video_Out_Control_1, 0, 2, RW, 0x0001, OUT_MODE_value_map, "Selects video output format"), DEFINE_SETTING_ENTRY("MODE10B", Video_Out_Control_1, 2, 1, RW, 0x0000, MODE10B_value_map, "Selects either 8-bit or 10-bit output for 4:2:2 Luma and Chroma"), DEFINE_SETTING_ENTRY("VBIHACTRAW_EN", Video_Out_Control_1, 3, 1, RW, 0x0000, VBIHACTRAW_EN_value_map, "Enables raw data output during the horizontal active region of the"), DEFINE_SETTING_ENTRY("ANC_DATA_EN", Video_Out_Control_1, 4, 1, RW, 0x0001, ANC_DATA_EN_value_map, "Enable Ancillary Data Insertion for BT.656 or VIP modes."), DEFINE_SETTING_ENTRY("TASKBIT_VAL", Video_Out_Control_1, 5, 1, RW, 0x0001, 0, "Task bit value in VIP 2 mode."), DEFINE_SETTING_ENTRY("BLUE_FIELD_ACT", Video_Out_Control_1, 6, 1, RW, 0x0000, 0, "Activate blue field on output regardless of BLUE_FIELD_EN"), DEFINE_SETTING_ENTRY("BLUE_FIELD_EN", Video_Out_Control_1, 7, 1, RW, 0x0000, BLUE_FIELD_EN_value_map, "Enable generation of blue field on output when decoder loses"), DEFINE_SETTING_ENTRY("CLAMPRAW_EN", Video_Out_Control_2, 0, 1, RW, 0x0001, CLAMPRAW_EN_value_map, "Enable clamping of raw ADC samples to 1254.75 when video"), DEFINE_SETTING_ENTRY("SWAPRAW", Video_Out_Control_2, 1, 1, RW, 0x0000, SWAPRAW_value_map, "Switch the positioning of the raw samples between the luma and"), DEFINE_SETTING_ENTRY("ACTFMT", Video_Out_Control_2, 2, 1, RW, 0x0001, ACTFMT_value_map, "Active signal format"), DEFINE_SETTING_ENTRY("VALIDFMT", Video_Out_Control_2, 3, 1, RW, 0x0000, VALIDFMT_value_map, "VALID signal format"), DEFINE_SETTING_ENTRY("HSFMT", Video_Out_Control_2, 4, 1, RW, 0x0000, HSFMT_value_map, "Selects width of HRESET_N"), DEFINE_SETTING_ENTRY("CLK_INVERT", Video_Out_Control_2, 5, 1, RW, 0x0001, 0, "When set, the pixel clock output is inverted."), DEFINE_SETTING_ENTRY("CLK_GATING", Video_Out_Control_2, 6, 2, RW, 0x0000, CLK_GATING_value_map, "Select pixel clock gating scheme"), DEFINE_SETTING_ENTRY("DCMODE", Video_Out_Control_3, 0, 1, RW, 0x0000, DCMODE_value_map, "Determines the format of the data count field in ancillary data in"), DEFINE_SETTING_ENTRY("IDID0_SOURCE", Video_Out_Control_3, 1, 1, RW, 0x0000, IDID0_SOURCE_value_map, "Source of IDID0 byte in VIP ancillary data"), DEFINE_SETTING_ENTRY("VIP_OPT_AL", Video_Out_Control_3, 2, 1, RW, 0x0000, VIP_OPT_AL_value_map, "VIP optional active line enable. In VIP modes, the transition of"), DEFINE_SETTING_ENTRY("VIPBLANK_EN", Video_Out_Control_3, 3, 1, RW, 0x0000, VIPBLANK_EN_value_map, "Enable substitution of blanking data during horizontal and"), DEFINE_SETTING_ENTRY("VIPCLAMP_EN", Video_Out_Control_3, 4, 1, RW, 0x0000, VIPCLAMP_EN_value_map, "Clamp luma and chroma data in VIP modes (i.e., when"), DEFINE_SETTING_ENTRY("POLAR", Video_Out_Control_4, 0, 7, RW, 0x0000, 0, "When bit is set, invert polarity of output"), DEFINE_SETTING_ENTRY("IDID0_9_2__LOW", Ancillary_IDID_0, 0, 8, RW, 0x0000, 0, "Value for IDID0 byte in VIP ancillary data. ([9:2] are used in 8-bit"), DEFINE_SETTING_ENTRY("IDID1_9_2__LOW", Ancillary_IDID_1, 0, 8, RW, 0x0000, 0, "Value for IDID0 byte in VIP ancillary data. ([9:2] are used in 8-bit"), DEFINE_SETTING_ENTRY("IDID0_1_0__HIGH", Ancillary_IDID_0_1, 0, 2, RW, 0x0000, 0, "Value for IDID0 byte in VIP ancillary data. ([1:0] are used in"), DEFINE_SETTING_ENTRY("IDID1_1_0__HIGH", Ancillary_IDID_0_1, 2, 2, RW, 0x0000, 0, "Value for IDID1 byte in VIP ancillary data. ([1:0] are used in"), DEFINE_SETTING_ENTRY("EN_A", Ancillary_Audio_Output_Control, 0, 1, RW, 0x0000, 0, "This bit enables data insertion from the FIFO_A in the VOF into"), DEFINE_SETTING_ENTRY("EN_B", Ancillary_Audio_Output_Control, 1, 1, RW, 0x0000, 0, "This bit enables data insertion from the FIFO_B in the VOF into"), DEFINE_SETTING_ENTRY("EN_C", Ancillary_Audio_Output_Control, 2, 1, RW, 0x0000, 0, "This bit enables data insertion from the FIFO_C in the VOF into"), DEFINE_SETTING_ENTRY("AUD_ANC_EN", Ancillary_Audio_Output_Control, 3, 1, RW, 0x0000, AUD_ANC_EN_value_map, "This bit enables audio ancillary data insertion. This bit, along"), DEFINE_SETTING_ENTRY("SAMPLE_RATE", Ancillary_Audio_Output_Control, 4, 2, RW, 0x0000, SAMPLE_RATE_value_map, "This indicates the sampling rate of the audio data available for"), DEFINE_SETTING_ENTRY("AUD_GRP", Ancillary_Audio_Output_Control, 6, 2, RW, 0x0000, AUD_GRP_value_map, "This field indicates the audio group that particular data flow"), DEFINE_SETTING_ENTRY("MV_CDAT", Copy_Protection_Status, 0, 2, RO, 0x0000, 0, "Macrovision Copy Control Bits as described in the MacroVision"), DEFINE_SETTING_ENTRY("MV_PSP", Copy_Protection_Status, 4, 1, RO, 0x0000, 0, "Macrovision Pseudo Sync Pulses detected"), DEFINE_SETTING_ENTRY("MV_CS", Copy_Protection_Status, 5, 1, RO, 0x0000, 0, "Macrovision Color Striping Detected"), DEFINE_SETTING_ENTRY("MV_T3CS", Copy_Protection_Status, 6, 1, RO, 0x0000, 0, "A 1 indicates the presence of type 3 of the color stripe process. A"), DEFINE_SETTING_ENTRY("MV_TYPE2_PAIR", Copy_Protection_Status, 7, 1, RO, 0x0000, 0, "Macrovision Type 2 pair detected"), DEFINE_SETTING_ENTRY("AFD_FMT_STAT", General_Status_1, 0, 4, RO, 0x0001, AFD_FMT_STAT_value_map, "Currently detected Format"), DEFINE_SETTING_ENTRY("FIELD", General_Status_1, 4, 1, RO, 0x0000, 0, "Field status (even/odd)"), DEFINE_SETTING_ENTRY("SRC_FIFO_OFLOW", General_Status_1, 5, 1, RO, 0x0000, 0, "Sample Rate Converter FIFO Overflow"), DEFINE_SETTING_ENTRY("SRC_FIFO_UFLOW", General_Status_1, 6, 1, RO, 0x0000, 0, "Sample Rate Converter FIFO Underflow"), DEFINE_SETTING_ENTRY("VSYNC", General_Status_1, 7, 1, RO, 0x0000, 0, "Vertical sync"), DEFINE_SETTING_ENTRY("HLOCK", General_Status_2, 0, 1, RO, 0x0000, 0, "Horizontal lock status"), DEFINE_SETTING_ENTRY("SRC_LOCK", General_Status_2, 1, 1, RO, 0x0000, 0, "Sample Rate Converter lock Status"), DEFINE_SETTING_ENTRY("VLOCK", General_Status_2, 2, 1, RO, 0x0000, 0, "Vertical lock status"), DEFINE_SETTING_ENTRY("CSC_LOCK", General_Status_2, 3, 1, RO, 0x0000, 0, "Color Subcarrier lock status"), DEFINE_SETTING_ENTRY("AGC_LOCK", General_Status_2, 4, 1, RO, 0x0000, 0, "VGA lock status"), DEFINE_SETTING_ENTRY("VPRES", General_Status_2, 5, 1, RO, 0x0000, 0, "Active-high video present. Indication of the presence of a"), DEFINE_SETTING_ENTRY("SPECIAL_PLAY_N", General_Status_2, 6, 1, RO, 0x0000, 0, "Active-low special play mode (fast forward, rewind, pulse, or slow"), DEFINE_SETTING_ENTRY("SRC_FIFO_OFLOW_STAT", Interrupt_Status_1, 0, 1, RR, 0x0000, 0, "The detection of a SRC FIFO Overflow sets this bit.Production Data Sheet5-60 Conexant 102284A"), DEFINE_SETTING_ENTRY("SRC_FIFO_UFLOW_STAT", Interrupt_Status_1, 1, 1, RR, 0x0000, 0, "The detection of a SRC FIFO Underflow sets this bit."), DEFINE_SETTING_ENTRY("CSC_LOCK_CHANGE_STAT", Interrupt_Status_1, 2, 1, RR, 0x0000, 0, "A change in the Color Subcarrier Lock status sets this bit."), DEFINE_SETTING_ENTRY("VLOCK_CHANGE_STAT", Interrupt_Status_1, 3, 1, RR, 0x0000, 0, "A change in the vertical lock status sets this bit."), DEFINE_SETTING_ENTRY("HLOCK_CHANGE_STAT", Interrupt_Status_1, 4, 1, RR, 0x0000, 0, "A change in the horizontal lock status sets this bit."), DEFINE_SETTING_ENTRY("VSYNC_TRAIL_STAT", Interrupt_Status_1, 5, 1, RR, 0x0000, 0, "The falling edge of the detected VSYNC sets this bit."), DEFINE_SETTING_ENTRY("FMT_CHANGE_STAT", Interrupt_Status_1, 6, 1, RR, 0x0000, 0, "A change in the detected video format sets this bit."), DEFINE_SETTING_ENTRY("END_VBI_ODD_STAT", Interrupt_Status_1, 7, 1, RR, 0x0000, 0, "The end of the VBI region of an odd field sets this bit."), DEFINE_SETTING_ENTRY("END_VBI_EVEN_STAT", Interrupt_Status_2, 0, 1, RR, 0x0000, 0, "The end of the VBI region of an even field sets this bit."), DEFINE_SETTING_ENTRY("MV_CHANGE_STAT", Interrupt_Status_2, 1, 1, RR, 0x0000, 0, "A change in the MV_CDAT field sets this bit."), DEFINE_SETTING_ENTRY("VPRES_CHANGE_STAT", Interrupt_Status_2, 2, 1, RR, 0x0000, 0, "A change in the VPRES (video present) status bit sets this bit."), DEFINE_SETTING_ENTRY("CC_DAT_AVAIL_STAT", Interrupt_Status_2, 3, 1, RR, 0x0000, 0, "VBI FIFO for Closed Caption has data (not empty)."), DEFINE_SETTING_ENTRY("GS1_DAT_AVAIL_STAT", Interrupt_Status_2, 4, 1, RR, 0x0000, 0, "VBI FIFO for Gemstar 1X has data (not empty)."), DEFINE_SETTING_ENTRY("GS2_DAT_AVAIL_STAT", Interrupt_Status_2, 5, 1, RR, 0x0000, 0, "VBI FIFO for Gemstar 2X has data (not empty)."), DEFINE_SETTING_ENTRY("WSS_DAT_AVAIL_STAT", Interrupt_Status_2, 6, 1, RR, 0x0000, 0, "VBI FIFO for Wide-Screen-Signaling has data (not empty)."), DEFINE_SETTING_ENTRY("SRC_FIFO_OFLOW_MSK", Interrupt_Mask_1, 0, 1, RW, 0x0001, 0, "When set, SRC_FIFO_OFLOW_STAT is masked from generating"), DEFINE_SETTING_ENTRY("SRC_FIFO_UFLOW_MSK", Interrupt_Mask_1, 1, 1, RW, 0x0001, 0, "When set, SRC_FIFO_UFLOW_STAT is masked from generating"), DEFINE_SETTING_ENTRY("CSC_LOCK_CHANGE_MSK", Interrupt_Mask_1, 2, 1, RW, 0x0001, 0, "When set, CSC_LOCK_CHANGE_STAT is masked from"), DEFINE_SETTING_ENTRY("VLOCK_CHANGE_MSK", Interrupt_Mask_1, 3, 1, RW, 0x0001, 0, "When set, VLOCK_CHANGE_STAT is masked from generating"), DEFINE_SETTING_ENTRY("HLOCK_CHANGE_MSK", Interrupt_Mask_1, 4, 1, RW, 0x0001, 0, "When set, HLOCK_CHANGE_STAT is masked from generating"), DEFINE_SETTING_ENTRY("VSYNC_TRAIL_MSK", Interrupt_Mask_1, 5, 1, RW, 0x0001, 0, "When set, VSYNC_TRAIL_STAT is masked from generating an"), DEFINE_SETTING_ENTRY("FMT_CHANGE_MSK", Interrupt_Mask_1, 6, 1, RW, 0x0001, 0, "When set, FMT_CHANGE_STAT is masked from generating an"), DEFINE_SETTING_ENTRY("END_VBI_ODD_MSK", Interrupt_Mask_1, 7, 1, RW, 0x0001, 0, "When set, END_VBI_ODD_STAT is masked from generating an"), DEFINE_SETTING_ENTRY("END_VBI_EVEN_MSK", Interrupt_Mask_2, 0, 1, RW, 0x0001, 0, "When set, END_VBI_EVEN_STAT is masked from"), DEFINE_SETTING_ENTRY("MV_CHANGE_MSK", Interrupt_Mask_2, 1, 1, RW, 0x0001, 0, "When set, MV_CHANGE_STAT is masked from"), DEFINE_SETTING_ENTRY("VPRES_CHANGE_MSK", Interrupt_Mask_2, 2, 1, RW, 0x0001, 0, "When set, VPRES_CHANGE_STAT is masked"), DEFINE_SETTING_ENTRY("CC_DAT_AVAIL_MSK", Interrupt_Mask_2, 3, 1, RR, 0x0000, 0, "When set, CC_DAT_AVAIL_STAT from generating"), DEFINE_SETTING_ENTRY("GS1_DAT_AVAIL_MSK", Interrupt_Mask_2, 4, 1, RR, 0x0000, 0, "When set, GS1_DAT_AVAIL_STAT from"), DEFINE_SETTING_ENTRY("GS2_DAT_AVAIL_MSK", Interrupt_Mask_2, 5, 1, RR, 0x0000, 0, "When set, GS2_DAT_AVAIL_STAT from"), DEFINE_SETTING_ENTRY("WSS_DAT_AVAIL_MSK", Interrupt_Mask_2, 6, 1, RR, 0x0000, 0, "When set, WSS_DAT_AVAIL_STAT is masked"), DEFINE_SETTING_ENTRY("BRIGHT", Brightness, 0, 8, RW, 0x0000, 0, "Brightness offset. This value is effectively an offset that is added"), DEFINE_SETTING_ENTRY("CNTRST", Contrast, 0, 8, RW, 0x0080, 0, "Contrast multiply value. This value is a 1.7 number that is"), DEFINE_SETTING_ENTRY("PEAK_SEL", Luma_Control, 0, 2, RW, 0x0000, PEAK_SEL_value_map, "Select for peaking filter response. This value selects from the four"), DEFINE_SETTING_ENTRY("PEAK_EN", Luma_Control, 2, 1, RW, 0x0000, PEAK_EN_value_map, "Peaking enable"), DEFINE_SETTING_ENTRY("RANGE", Luma_Control, 4, 2, RW, 0x0000, RANGE_value_map, "Selects the allowed luma output range. This allows the user to"), DEFINE_SETTING_ENTRY("LUMA_CORE_SEL", Luma_Control, 6, 2, RW, 0x0000, LUMA_CORE_SEL_value_map, "Luma coring threshold select. This value determines the cutoff"), DEFINE_SETTING_ENTRY("HSCALE", Horizontal_Scaling_Low, 0, 24, RW, 0x0000, 0, "Least significant byte of Horizontal Scaling Ratio (hscale ="), DEFINE_SETTING_ENTRY("HFILT", Horizontal_Scaling_Control, 0, 2, RW, 0x0000, HFILT_value_map, "Low-pass filter select. This is used in the luma low-pass filter"), DEFINE_SETTING_ENTRY("VSCALE", Vertical_Scaling_Low, 0, 13, RW, 0x0000, 0, "Least significant byte of Vertical Scaling Ratio (vsf = 216"), DEFINE_SETTING_ENTRY("VFILT", Vertical_Scaling_Control, 0, 3, RW, 0x0000, VFILT_value_map, "These bits control the number of taps in the Vertical Scaling"), DEFINE_SETTING_ENTRY("VS_INTRLACE", Vertical_Scaling_Control, 3, 1, RW, 0x0000, VS_INTRLACE_value_map, "VS Interlace Format. The initial output phase must alternate if the"), DEFINE_SETTING_ENTRY("LINE_AVG_DIS", Vertical_Line_Control, 0, 1, RW, 0x0000, LINE_AVG_DIS_value_map, "PAL line average disable"), DEFINE_SETTING_ENTRY("USAT", Saturation_U, 0, 8, RW, 0x0080, 0, "Saturation adjust for U chroma"), DEFINE_SETTING_ENTRY("VSAT", Saturation_V, 0, 8, RW, 0x0080, 0, "Saturation adjust for V chroma"), DEFINE_SETTING_ENTRY("HUE", Hue, 0, 8, RW, 0x0000, 0, "Hue adjust. A 1-bit change causes the subcarrier phase to rotate"), DEFINE_SETTING_ENTRY("C_CORE_SEL", Chroma_Control, 0, 2, RW, 0x0000, C_CORE_SEL_value_map, "Chroma coring select."), DEFINE_SETTING_ENTRY("CHR_DELAY", Chroma_Control, 2, 3, RW, 0x0000, CHR_DELAY_value_map, "Chroma delay. A signed number representing the number of"), DEFINE_SETTING_ENTRY("VBI_MD_LINE1", VBI_Line_Control_1, 0, 8, RW, 0x0000, VBI_MD_LINE1_value_map, "1st VBI line data type"), DEFINE_SETTING_ENTRY("VBI_MD_LINE2", VBI_Line_Control_2, 0, 8, RW, 0x0000, 0, "2nd VBI line data type. Valid programmed values are the same as"), DEFINE_SETTING_ENTRY("VBI_MD_LINE3", VBI_Line_Control_3, 0, 8, RW, 0x0000, 0, "3rd VBI line data type. Valid programmed values are the same as"), DEFINE_SETTING_ENTRY("VBI_MD_LINE4", VBI_Line_Control_4, 0, 8, RW, 0x0000, 0, "4th VBI line data type. Valid programmed values are the same as"), DEFINE_SETTING_ENTRY("VBI_MD_LINE5", VBI_Line_Control_5, 0, 8, RW, 0x0000, 0, "5th VBI line data type. Valid programmed values are the same as"), DEFINE_SETTING_ENTRY("VBI_MD_LINE6", VBI_Line_Control_6, 0, 8, RW, 0x0000, 0, "6th VBI line data type. Valid programmed values are the same as"), DEFINE_SETTING_ENTRY("VBI_MD_LINE7", VBI_Line_Control_7, 0, 8, RW, 0x0000, 0, "7th VBI line data type. Valid programmed values are the same as"), DEFINE_SETTING_ENTRY("VBI_MD_LINE8", VBI_Line_Control_8, 0, 8, RW, 0x0000, 0, "8th VBI line data type. Valid programmed values are the same as"), DEFINE_SETTING_ENTRY("VBI_MD_LINE9", VBI_Line_Control_9, 0, 8, RW, 0x0000, 0, "9th VBI line data type. Valid programmed values are the same as"), DEFINE_SETTING_ENTRY("VBI_MD_LINE10", VBI_Line_Control_10, 0, 8, RW, 0x0000, 0, "10th VBI line data type. Valid programmed values are the same"), DEFINE_SETTING_ENTRY("VBI_MD_LINE11", VBI_Line_Control_11, 0, 8, RW, 0x0000, 0, "11th VBI line data type. Valid programmed values are the same"), DEFINE_SETTING_ENTRY("VBI_MD_LINE12", VBI_Line_Control_12, 0, 8, RW, 0x0000, 0, "12th VBI line data type. Valid programmed values are the same"), DEFINE_SETTING_ENTRY("VBI_MD_LINE13", VBI_Line_Control_13, 0, 8, RW, 0x0000, 0, "13th VBI line data type. Valid programmed values are the same"), DEFINE_SETTING_ENTRY("VBI_MD_LINE14", VBI_Line_Control_14, 0, 8, RW, 0x0000, 0, "14th VBI line data type. Valid programmed values are the same"), DEFINE_SETTING_ENTRY("VBI_MD_LINE15", VBI_Line_Control_15, 0, 8, RW, 0x0000, 0, "15th VBI line data type. Valid programmed values are the same"), DEFINE_SETTING_ENTRY("VBI_MD_LINE16", VBI_Line_Control_16, 0, 8, RW, 0x0000, 0, "16th VBI line data type. Valid programmed values are the same"), DEFINE_SETTING_ENTRY("VBI_MD_LINE17", VBI_Line_Control_17, 0, 8, RW, 0x0000, 0, "17th VBI line data type. Valid programmed values are the same"), DEFINE_SETTING_ENTRY("FC_SEARCH_MODE", VBI_Frame_Code_Search_Mode, 0, 1, RW, 0x0000, FC_SEARCH_MODE_value_map, "Frame code search mode. Allows dynamic search from frame"), DEFINE_SETTING_ENTRY("FC_ALT1_TYPE", VBI_Alternate_Frame_Code_Type, 0, 4, RW, 0x0000, 0, "When this field matches the VBIMODE setting for a particular"), DEFINE_SETTING_ENTRY("FC_ALT2_TYPE", VBI_Alternate_Frame_Code_Type, 4, 4, RW, 0x0000, 0, "When this field matches the VBIMODE setting for a particular"), DEFINE_SETTING_ENTRY("FC_ALT1", VBI_Alternate_1_Frame_Code, 0, 8, RW, 0x0000, 0, "Alternate frame code used when VBIMODE matches"), DEFINE_SETTING_ENTRY("FC_ALT2", VBI_Alternate_2_Frame_Code, 0, 8, RW, 0x0000, 0, "Alternate frame code used when VBIMODE matches"), DEFINE_SETTING_ENTRY("ADAPT_SLICE_DIS", VBI_Miscellaneous_Config_1, 0, 1, RW, 0x0000, ADAPT_SLICE_DIS_value_map, "Disable adaptive slice level"), DEFINE_SETTING_ENTRY("EDGE_RESYNC_EN", VBI_Miscellaneous_Config_1, 1, 1, RW, 0x0001, EDGE_RESYNC_EN_value_map, "Enable dynamic timing resynchronization based on edge"), DEFINE_SETTING_ENTRY("CRI_MARG_SCALE", VBI_Miscellaneous_Config_1, 2, 2, RW, 0x0001, CRI_MARG_SCALE_value_map, "Clock run-in margin scale. Used to loosen or tighten lock criteria"), DEFINE_SETTING_ENTRY("VPS_DEC_DIS", VBI_Miscellaneous_Config_1, 4, 1, RW, 0x0000, VPS_DEC_DIS_value_map, "VPS biphase decode disable."), DEFINE_SETTING_ENTRY("MOJI_PACK_DIS", VBI_Miscellaneous_Config_1, 5, 1, RW, 0x0000, MOJI_PACK_DIS_value_map, "Moji packing disable."), DEFINE_SETTING_ENTRY("TTX_PKTADRL_LB", TTX_Packet_Address_1, 0, 8, RW, 0x0000, 0, "Low byte of Teletext packet address lower limit for packet"), DEFINE_SETTING_ENTRY("TTX_PKTADRL_HN", TTX_Packet_Address_2, 0, 4, RW, 0x0000, 0, "High nibble of Teletext packet address lower limit for packet"), DEFINE_SETTING_ENTRY("TTX_PKTADRU_LN", TTX_Packet_Address_2, 4, 4, RW, 0x0457, 0, "Low nibble of Teletext packet address upper limit for packet"), DEFINE_SETTING_ENTRY("TTX_PKTADRU_HB", TTX_Packet_Address_3, 0, 8, RW, 0x00ff, 0, "High byte of Teletext packet address upper limit for packet"), DEFINE_SETTING_ENTRY("VBI1_SDID", VBI_1_and_2_SDID, 0, 4, RW, 0x03e9, 0, "SDID to use when VBI_CUST1 data type is selected."), DEFINE_SETTING_ENTRY("VBI2_SDID", VBI_1_and_2_SDID, 4, 4, RW, 0x03f2, 0, "SDID to use when VBI_CUST2 data type is selected."), DEFINE_SETTING_ENTRY("VBI3_SDID", VBI_3_SDID, 0, 4, RW, 0x03f3, 0, "SDID to use when VBI_CUST3 data type is selected."), DEFINE_SETTING_ENTRY("CC_FIFO_RST", VBI_FIFO_Reset, 0, 1, RW, 0x0000, 0, "When = 1, reset Closed Caption/XDS payload FIFO"), DEFINE_SETTING_ENTRY("GS1_FIFO_RST", VBI_FIFO_Reset, 1, 1, RW, 0x0000, 0, "When = 1, reset Gemstar1x payload FIFO"), DEFINE_SETTING_ENTRY("GS2_FIFO_RST", VBI_FIFO_Reset, 2, 1, RW, 0x0000, 0, "When = 1, reset Gemstar2x payload FIFO"), DEFINE_SETTING_ENTRY("WSS_FIFO_RST", VBI_FIFO_Reset, 3, 1, RW, 0x0000, 0, "When = 1, reset WSS payload FIFO"), DEFINE_SETTING_ENTRY("HAMMING_TYPE", VBI_Hamming, 0, 4, RW, 0x0000, 0, "When this field matches the VBIMODE setting for a"), DEFINE_SETTING_ENTRY("CC_STAT", Closed_Caption_Status, 0, 8, RO, 0x0000, 0, "Generic payload status format:"), DEFINE_SETTING_ENTRY("CC_FIFO_DAT", Closed_Caption_Data, 0, 8, RO, 0x0000, 0, "0x00 CC_FIFO_DAT CC/XDS payload data. Data pointer advanced after reading"), DEFINE_SETTING_ENTRY("GS1_STAT", GEMSTAR_1x_Status, 0, 8, RO, 0x0000, 0, "See description of CC_STAT byte."), DEFINE_SETTING_ENTRY("GS1_FIFO_DAT", GEMSTAR_1x_Data, 0, 8, RO, 0x0000, 0, "0x00 GS1_FIFO_DAT Gemstar 1x payload data. Data pointer advanced after"), DEFINE_SETTING_ENTRY("GS2_STAT", GEMSTAR_2x_Status, 0, 8, RO, 0x0000, 0, "See description of CC_STAT byte"), DEFINE_SETTING_ENTRY("GS2_FIFO_DAT", GEMSTAR_2x_Data, 0, 8, RO, 0x0000, 0, "0x00 GS2_FIFO_DAT Gemstar 2x payload data. Data pointer advanced after"), DEFINE_SETTING_ENTRY("WSS_STAT", WSS_Status, 0, 8, RO, 0x0000, 0, "See description of CC_STAT byte (PARERR will be held at"), DEFINE_SETTING_ENTRY("WSS_FIFO_DAT", WSS_Data, 0, 8, RO, 0x0000, 0, "0x00 WSS_FIFO_DAT Wide Screen Signaling payload data. Data pointer advanced"), DEFINE_SETTING_ENTRY("VBI1_HDELAY", VBI_Custom_1_Horizontal_Delay, 0, 8, RW, 0x0070, 0, "Delay from internal hreset signal to start of clock run-in in"), DEFINE_SETTING_ENTRY("VBI1_BITINC", VBI_Custom_1_Bit_Increment, 0, 12, RW, 0x0099, 0, "Least significant byte of the value used to increment a 14-bit"), DEFINE_SETTING_ENTRY("VBI1_SLICE_DIST", VBI_Custom_1_Slice_Distance, 4, 4, RW, 0x0001, 0, "Slice level sample distance. Controls how often samples are"), DEFINE_SETTING_ENTRY("VBI1_CRWIN", VBI_Custom_1_Clock_Run_in_Window, 0, 7, RW, 0x002c, 0, "Specifies the time window during which edge detection (positive"), DEFINE_SETTING_ENTRY("VBI1_FRAME_CODE", VBI_Custom_1_Frame_Code_Low, 0, 24, RW, 0x000001, 0, "Least significant byte of start code bit pattern in transmission"), DEFINE_SETTING_ENTRY("VBI1_FC_LENGTH", VBI_Custom_1_Frame_Code_Length, 0, 5, RW, 0x0003, 0, "Number of start bits (or frame code bits)"), DEFINE_SETTING_ENTRY("VBI1_CRI_TIME", VBI_Custom_1_Clock_Run_in_Period, 0, 8, RW, 0x000d, 0, "Expected time period of clock run-in period in terms of halves of"), DEFINE_SETTING_ENTRY("VBI1_CRI_MARGIN", VBI_Custom_1_Clock_Run_in_Margin_and_Length, 0, 4, RW, 0x0004, 0, "This field specifies the margin around VBI1_CRI_TIME in which"), DEFINE_SETTING_ENTRY("VBI1_CRI_LENGTH", VBI_Custom_1_Clock_Run_in_Margin_and_Length, 4, 4, RW, 0x000c, 0, "Number of clock run-in edges expected in the CRI period. This"), DEFINE_SETTING_ENTRY("VBI1_PAYLD_LENGTH", VBI_Custom_1_Payload_Length, 0, 8, RW, 0x0008, 0, "Number of data bits to be captured, divided by two. If N is the"), DEFINE_SETTING_ENTRY("VBI1_FORMAT_TYPE", VBI_Custom_1_Miscellaneous, 0, 4, RW, 0x0006, VBI1_FORMAT_TYPE_value_map, "Specifies basic VBI decoding model. Find the standard format"), DEFINE_SETTING_ENTRY("VBI1_FIFO_MODE", VBI_Custom_1_Miscellaneous, 4, 3, RW, 0x0008, VBI1_FIFO_MODE_value_map, "Determines which payload FIFO is loaded."), DEFINE_SETTING_ENTRY("VBI1_HAM_EN", VBI_Custom_1_Miscellaneous, 7, 1, RW, 0x0000, 0, "Enable hamming comparison for framing comparison when"), DEFINE_SETTING_ENTRY("VBI2_HDELAY", VBI_Custom_2_Horizontal_Delay, 0, 8, RW, 0x0077, 0, "Delay from internal hreset signal to start of clock run-in in"), DEFINE_SETTING_ENTRY("VBI2_BITINC", VBI_Custom_2_Bit_Increment, 0, 12, RW, 0x0088, 0, "Least significant byte of the value used to increment a 14-bit"), DEFINE_SETTING_ENTRY("VBI2_SLICE_DIST", VBI_Custom_2_Slice_Distance, 4, 4, RW, 0x0000, 0, "Slice level sample distance. Controls how often samples are"), DEFINE_SETTING_ENTRY("VBI1_CRIWIN", VBI_Custom_2_Clock_Run_In_Window, 0, 7, RW, 0x002c, 0, "Specifies the time window during which edge detection"), DEFINE_SETTING_ENTRY("VBI2_FRAME_CODE", VBI_Custom_2_Frame_Code_Low, 0, 24, RW, 0x000000, 0, "Least significant byte of start code bit pattern in transmission"), DEFINE_SETTING_ENTRY("VBI2_FC_LENGTH", VBI_Custom_2_Frame_Code_Length, 0, 5, RW, 0x0000, 0, "Number of start bits (or frame code bits)"), DEFINE_SETTING_ENTRY("VBI2_CRI_TIME", VBI_Custom_2_Clock_Run_in_Period, 0, 8, RW, 0x0002, 0, "Expected time period of clock run-in period in terms of"), DEFINE_SETTING_ENTRY("VBI2_CRI_MARGIN", VBI_Custom_2_Clock_Run_in_Margin_and_Length, 0, 4, RW, 0x0004, 0, "This field specifies the margin around VBI1_CRI_TIME in"), DEFINE_SETTING_ENTRY("VBI2_CRI_LENGTH", VBI_Custom_2_Clock_Run_in_Margin_and_Length, 4, 4, RW, 0x0001, 0, "Number of clock run-in edges expected in the CRI period."), DEFINE_SETTING_ENTRY("VBI2_PAYLD_LENGTH", VBI_Custom_2_Payload_Length, 0, 8, RW, 0x000a, 0, "Number of data bits to be captured, divided by two. If N is the"), DEFINE_SETTING_ENTRY("VBI2_FORMAT_TYPE", VBI_Custom_2_Miscellaneous, 0, 4, RW, 0x0004, VBI2_FORMAT_TYPE_value_map, "Specifies basic VBI decoding model. Find the standard format"), DEFINE_SETTING_ENTRY("VBI2_FIFO_MODE", VBI_Custom_2_Miscellaneous, 4, 3, RW, 0x0009, VBI2_FIFO_MODE_value_map, "Determines which payload FIFO is loaded."), DEFINE_SETTING_ENTRY("VBI2_HAM_EN", VBI_Custom_2_Miscellaneous, 7, 1, RW, 0x0000, 0, "Enable hamming comparison for framing comparison when"), DEFINE_SETTING_ENTRY("VBI3_HDELAY", VBI_Custom_3_Horizontal_Delay, 0, 8, RW, 0x006e, 0, "Delay from internal hreset signal to start of clock run-in in"), DEFINE_SETTING_ENTRY("VBI3_BITINC", VBI_Custom_3_Bit_Increment, 0, 12, RW, 0x06ca, 0, "Least significant byte of the value used to increment a 14-bit"), DEFINE_SETTING_ENTRY("VBI3_SLICE_DIST", VBI_Custom_3_Slice_Distance, 4, 4, RW, 0x0003, 0, "Slice level sample distance. Controls how often samples are"), DEFINE_SETTING_ENTRY("VBI3_CRWIN", VBI_Custom_3_Clock_Run_in_Window, 0, 7, RW, 0x0006, 0, "Specifies the time window during which edge detection"), DEFINE_SETTING_ENTRY("VBI3_FRAME_CODE", VBI_Custom_3_Frame_Code_Low, 0, 24, RW, 0x00e7, 0, "Least significant byte of start code bit pattern in transmission"), DEFINE_SETTING_ENTRY("VBI3_FC_LENGTH", VBI_Custom_3_Frame_Code_Length, 0, 5, RW, 0x0008, 0, "Number of start bits (or frame code bits)"), DEFINE_SETTING_ENTRY("VBI3_CRI_TIME", VBI_Custom_3_Clock_Run_in_Period, 0, 8, RW, 0x0020, 0, "Expected time period of clock run-in period in terms of halves"), DEFINE_SETTING_ENTRY("VBI3_CRI_MARGIN", VBI_Custom_3_Clock_Run_in_Margin_and_Length, 0, 4, RW, 0x0006, 0, "This field specifies the margin around VBI3_CRI_TIME in"), DEFINE_SETTING_ENTRY("VBI3_CRI_LENGTH", VBI_Custom_3_Clock_Run_in_Margin_and_Length, 4, 4, RW, 0x000f, 0, "Number of clock run-in edges expected in the CRI period. This"), DEFINE_SETTING_ENTRY("VBI3_PAYLD_LENGTH", VBI_Custom_3_Payload_Length, 0, 8, RW, 0x0084, 0, "Number of data bits to be captured, divided by two. If N is the"), DEFINE_SETTING_ENTRY("VBI3_FORMAT_TYPE", VBI_Custom_3_Miscellaneous, 0, 4, RW, 0x0002, VBI3_FORMAT_TYPE_value_map, "Specifies basic VBI decoding model. Find the standard format"), DEFINE_SETTING_ENTRY("VBI3_FIFO_MODE", VBI_Custom_3_Miscellaneous, 4, 3, RW, 0x0000, VBI3_FIFO_MODE_value_map, "Determines which payload FIFO is loaded."), DEFINE_SETTING_ENTRY("VBI3_HAM_EN", VBI_Custom_3_Miscellaneous, 7, 1, RW, 0x0000, 0, "Enable hamming comparison for framing comparison when"), DEFINE_SETTING_ENTRY("HBLANK_CNT", Horizontal_Blanking_Delay_Low, 0, 10, VO, 0x007a, 0, "Lower 8-bits of horizontal blanking delay. It is number of"), DEFINE_SETTING_ENTRY("HACTIVE_CNT", Horizontal_Blanking_Delay_High, 4, 10, VO, 0x0000, 0, "Lower nibble of horizontal active region duration. It is the"), DEFINE_SETTING_ENTRY("BGDEL_CNT", Burst_Gate_Delay, 0, 8, VO, 0x005b, 0, "Burst gate delay. This value is used to generate the window"), DEFINE_SETTING_ENTRY("VBLANK_CNT", Vertical_Blanking_Delay_Low, 0, 10, VO, 0x0014, 0, "Lower 8-bits of vertical blanking delay. It is the number of"), DEFINE_SETTING_ENTRY("VACTIVE_CNT", Vertical_Blanking_Delay_High, 4, 10, VO, 0x00f7, 0, "Lower nibble of vertical active region duration. It is the"), DEFINE_SETTING_ENTRY("V656BLANK_CNT", Vertical_Blanking_Delay_656, 0, 8, VO, 0x0020, 0, "Vertical blanking for 656 output. Determines the timing of"), DEFINE_SETTING_ENTRY("SRC_DECIM_RATIO", SRC_Decimation_Ratio_Low, 0, 10, VO, 0x021f, 0, "Lower byte of sample rate converter decimation ratio."), DEFINE_SETTING_ENTRY("UV_LPF_SEL", Comb_Filter_Bandwidth_Select, 4, 2, VO, 0x0001, UV_LPF_SEL_value_map, "Selects U/V low-pass filter bandwidth:"), DEFINE_SETTING_ENTRY("LUMA_LPF_SEL", Comb_Filter_Bandwidth_Select, 6, 2, VO, 0x0001, LUMA_LPF_SEL_value_map, "Selects luma low-pass filter bandwidth:"), DEFINE_SETTING_ENTRY("LCOMB_2LN_EN", Comb_Filter_Enable, 1, 1, VO, 0x0001, LCOMB_2LN_EN_value_map, "Enables the adaptation algorithm to choose the 2-line luma"), DEFINE_SETTING_ENTRY("LCOMB_3LN_EN", Comb_Filter_Enable, 2, 1, VO, 0x0001, LCOMB_3LN_EN_value_map, "Enables the adaptation algorithm to choose the 3-line luma"), DEFINE_SETTING_ENTRY("CCOMB_2LN_EN", Comb_Filter_Enable, 5, 1, VO, 0x0001, CCOMB_2LN_EN_value_map, "Enables the adaptation algorithm to choose the 2-line chroma"), DEFINE_SETTING_ENTRY("CCOMB_3LN_EN", Comb_Filter_Enable, 6, 1, VO, 0x0001, CCOMB_3LN_EN_value_map, "Enables the adaptation algorithm to choose the 3-line chroma"), DEFINE_SETTING_ENTRY("SC_STEP", Subcarrier_Step_Size_Low, 0, 24, VO, 0x087c1f, 0, "Lower byte of the chroma subcarrier DTO step size value."), DEFINE_SETTING_ENTRY("VBI_OFFSET", VBI_Offset, 0, 5, VO, 0x0000, 0, "The offset in lines from VRESET/HCTL/PRGM3 to enable the"), DEFINE_SETTING_ENTRY("FIELD_COUNT", Field_Count_Low, 0, 10, VO, 0x0000, 0, "Lower byte of the count value. Counts fields continuously,"), DEFINE_SETTING_ENTRY("TEMPDEC", Temporal_Decimation, 0, 6, RW, 0x0000, 0, "This signal is the control for the temporal decimation logic."), DEFINE_SETTING_ENTRY("TDFIELD", Miscellaneous_Timing_Control, 1, 1, RW, 0x0000, 0, "This signal is an indication of whether the temporal"), DEFINE_SETTING_ENTRY("TDALGN", Miscellaneous_Timing_Control, 2, 1, RW, 0x0000, TDALGN_value_map, "Aligns start of decimation with even or odd field."), DEFINE_SETTING_ENTRY("HR32", Miscellaneous_Timing_Control, 3, 1, RW, 0x0000, HR32_value_map, "This bit controls the width of the HRESET output."), DEFINE_SETTING_ENTRY("VPRES_VERT_EN", Miscellaneous_Timing_Control, 7, 1, RW, 0x0000, VPRES_VERT_EN_value_map, "Enable for the vertical portion of the video present logic."), DEFINE_SETTING_ENTRY("VT_LINE_CNT_HYST", Video_Detect_Configuration, 4, 2, RW, 0x0000, VT_LINE_CNT_HYST_value_map, "Number of consecutive fields with approximately 525/2 or"), DEFINE_SETTING_ENTRY("DEBOUNCE_COUNT", Video_Detect_Configuration, 6, 2, RW, 0x0001, DEBOUNCE_COUNT_value_map, "Number of consecutive fields of detected video format stability"), DEFINE_SETTING_ENTRY("VGA_GAIN", VGA_Gain_Control, 0, 6, RW, 0x0020, 0, ""), DEFINE_SETTING_ENTRY("AGC_GAIN", AGC_Gain_Control_Low, 0, 12, RW, 0x0100, 0, ""), DEFINE_SETTING_ENTRY("CLAMP_LEVEL", Digital_Front_End_Control, 0, 3, RW, 0x0000, 0, "Analog clamp setting (if CLAMP_AUTO_EN = 0)"), DEFINE_SETTING_ENTRY("VBI_GATE_EN", Digital_Front_End_Control, 3, 1, RW, 0x0001, 0, "Enable gating of back porch updates during vertical blanking"), DEFINE_SETTING_ENTRY("VGA_AUTO_EN", Digital_Front_End_Control, 4, 1, RW, 0x0001, VGA_AUTO_EN_value_map, "VGA enable"), DEFINE_SETTING_ENTRY("VGA_CRUSH_EN", Digital_Front_End_Control, 5, 1, RW, 0x0001, 0, "ADC overflow protection enable (decreases VGA_SYNC if ADC"), DEFINE_SETTING_ENTRY("AGC_AUTO_EN", Digital_Front_End_Control, 6, 1, RW, 0x0001, AGC_AUTO_EN_value_map, "AGC enable"), DEFINE_SETTING_ENTRY("CLAMP_AUTO_EN", Digital_Front_End_Control, 7, 1, RW, 0x0001, CLAMP_AUTO_EN_value_map, "Analog clamp setting is tied to VGA gain"), DEFINE_SETTING_ENTRY("VGA_SYNC", VGA_Sync_Control, 0, 8, RW, 0x00dc, 0, "Sync pulse height out of ADC"), DEFINE_SETTING_ENTRY("VGA_TRACK_RANGE", VGA_Track_Range, 0, 8, RW, 0x0040, 0, "Minimum error of sync height before losing VGA lock"), DEFINE_SETTING_ENTRY("VGA_ACQUIRE_RANGE", VGA_Acquire_Range, 0, 8, RW, 0x0010, 0, "Maximum error of sync height before declaring VGA lock."), DEFINE_SETTING_ENTRY("DCC_LOOP_GAIN", DFE_Control, 0, 2, RW, 0x000a, 0, "Backporch clamp control loop gain = 2n/4"), DEFINE_SETTING_ENTRY("AGC_LOOP_GAIN", DFE_Control, 2, 2, RW, 0x000a, 0, "AGC control loop gain = 2n/4"), DEFINE_SETTING_ENTRY("SYNC_LOOP_GAIN", DFE_Control, 6, 2, RW, 0x000a, 0, "Sync level detect control loop gain = 2n/4"), DEFINE_SETTING_ENTRY("BP_LOOP_GAIN", Backporch_Loop_Gain, 0, 2, RW, 0x000a, 0, "Backporch level detect control loop gain = 2n/4"), DEFINE_SETTING_ENTRY("DFT_THRESHOLD", DFT_Threshold, 0, 8, RW, 0x003f, 0, "Correlator threshold for SC detect (threshold = 256 x setting)."), DEFINE_SETTING_ENTRY("BP_PERCENT", Backporch_Percent, 0, 8, RW, 0x00cd, 0, "Percent of line expected to be used above or equal to"), DEFINE_SETTING_ENTRY("PLL_MAX_OFFSET", PLL_Offset_Low, 0, 16, RW, 0x0300, 0, "Least significant byte of video PLL maximum adjustment"), DEFINE_SETTING_ENTRY("PLL_KI", PLL_Indirect_Loop_Gain, 0, 8, RW, 0x001f, 0, "PLL control loop indirect gain = 1/2(n+11)"), DEFINE_SETTING_ENTRY("PLL_KD", PLL_Direct_Loop_Gain, 0, 8, RW, 0x0016, 0, "PLL control loop indirect gain = 1/2n"), DEFINE_SETTING_ENTRY("HTL_KI", Horizontal_Tracking_Loop_Indirect_Gain, 0, 2, RW, 0x000a, 0, "Horizontal tracking loop indirect gain = 1/2n"), DEFINE_SETTING_ENTRY("HTL_KD", Horizontal_Tracking_Loop_Indirect_Gain, 4, 2, RW, 0x000a, 0, "Horizontal tracking loop indirect gain = 1/2n"), DEFINE_SETTING_ENTRY("LCOMB_ERR_LIMIT", Luma_Comb_Error_Limit_Max, 0, 8, RW, 0x0014, 0, "Maximum comb error before falling back to complementary"), DEFINE_SETTING_ENTRY("LUMA_THRESHOLD", Luma_Comb_Threshold, 0, 8, RW, 0x0000, 0, "Minimum chroma amplitude before using luma comb filter."), DEFINE_SETTING_ENTRY("CCOMB_ERR_LIMIT", Chroma_Comb_Error_Limit_Max, 0, 8, RW, 0x0050, 0, "Maximum comb error before falling back to notch filter mode."), DEFINE_SETTING_ENTRY("COMB_PHASE_LIMIT", Comb_Phase_Limit_Max, 0, 8, RW, 0x0020, 0, "Comb filter is enabled when the burst phase difference"), DEFINE_SETTING_ENTRY("SYNC_TIP_INC", White_Crush_Increment, 0, 6, RW, 0x000f, 0, "White crush increment value. This value is the step amount"), DEFINE_SETTING_ENTRY("SYNC_TIP_REDUCE", White_Crush_Decrement, 1, 6, RW, 0x0000, 0, "White crush decrement value. This value is the step amount"), DEFINE_SETTING_ENTRY("MAJ_SEL", White_Crush_Comparison_Point, 2, 2, RW, 0x000b, MAJ_SEL_value_map, "White crush majority comparison point select bits. This"), DEFINE_SETTING_ENTRY("MAJ_SEL_EN", White_Crush_Comparison_Point, 4, 1, RW, 0x0000, MAJ_SEL_EN_value_map, "Enables adaptive majority select logic."), DEFINE_SETTING_ENTRY("CRUSH_FREQ", White_Crush_Comparison_Point, 5, 1, RW, 0x0000, CRUSH_FREQ_value_map, "White crush adjust frequency. This bit is used to determine"), DEFINE_SETTING_ENTRY("WTW_EN", White_Crush_Comparison_Point, 6, 1, RW, 0x0000, WTW_EN_value_map, "Active-high enable for the white crush whiter-than-white"), DEFINE_SETTING_ENTRY("DFE_RST_MSK", Soft_Reset_Mask_1, 1, 1, RW, 0x0000, 0, "Masks soft reset for the Digital Front End module"), DEFINE_SETTING_ENTRY("SRC_RST_MSK", Soft_Reset_Mask_1, 2, 1, RW, 0x0000, 0, "Masks soft reset for the Sample Rate Converter module"), DEFINE_SETTING_ENTRY("YCSEP_RST_MSK", Soft_Reset_Mask_1, 3, 1, RW, 0x0000, 0, "Masks soft reset for the Y/C separation module"), DEFINE_SETTING_ENTRY("VTG_RST_MSK", Soft_Reset_Mask_1, 4, 1, RW, 0x0000, 0, "Masks soft reset for the Video Timing Generator module"), DEFINE_SETTING_ENTRY("LUMA_RST_MSK", Soft_Reset_Mask_1, 5, 1, RW, 0x0000, 0, "Masks soft reset for the Luma Datapath module"), DEFINE_SETTING_ENTRY("CHROMA_RST_MSK", Soft_Reset_Mask_1, 6, 1, RW, 0x0000, 0, "Masks soft reset for the Chroma Datapath module"), DEFINE_SETTING_ENTRY("SCALE_RST_MSK", Soft_Reset_Mask_1, 7, 1, RW, 0x0000, 0, "Masks soft reset for the Scaling module"), DEFINE_SETTING_ENTRY("VBI_RST_MSK", Soft_Reset_Mask_2, 0, 1, RW, 0x0000, 0, "Masks soft reset for the VBI slicer module"), DEFINE_SETTING_ENTRY("MVDET_RST_MSK", Soft_Reset_Mask_2, 1, 1, RW, 0x0000, 0, "Masks soft reset for the Macrovision Detect module"), DEFINE_SETTING_ENTRY("VOF_RST_MSK", Soft_Reset_Mask_2, 2, 1, RW, 0x0000, 0, "Masks soft reset for the Video Output Formatter module"), DEFINE_SETTING_ENTRY("REG_RST_MSK", Soft_Reset_Mask_2, 3, 1, RW, 0x0000, 0, "Masks soft reset for the Register module"), DEFINE_SETTING_ENTRY("VD_SOFT_RST", Soft_Reset_Mask_2, 7, 1, RW, 0x0000, 0, "Video decoder soft reset. Resets video decoder core per the"), DEFINE_SETTING_ENTRY("REV_ID", Version_ID, 0, 8, RO, 0x0002, 0, "Revision ID. The initial value is set to 0x01. This refers to"), DEFINE_SETTING_ENTRY("APL_DETECT_ENA", Miscellaneous_Diagnostic_Control, 0, 1, RW, 0x000a, APL_DETECT_ENA_value_map, "Enables detection of video pattern with one white line"), DEFINE_SETTING_ENTRY("DL_ADDR_LB", Download_Address_Low_Byte, 0, 8, RW, 0x0000, 0, "Address lower byte for embedded"), DEFINE_SETTING_ENTRY("DL_ADDR_HB", Download_Address_High_Byte, 0, 8, RW, 0x0000, 0, "Address higher byte for embedded"), DEFINE_SETTING_ENTRY("DL_DATA_CTL", Download_Data_Control, 0, 8, RW, 0x0000, 0, "Control data port for embedded microcontroller"), DEFINE_SETTING_ENTRY("DL_MAP", Download_Control, 0, 2, RW, 0x0000, 0, "Memory map mode"), DEFINE_SETTING_ENTRY("DL_AUTO_INC", Download_Control, 2, 1, RW, 0x0000, DL_AUTO_INC_value_map, "Increment Mode"), DEFINE_SETTING_ENTRY("DL_ENABLE", Download_Control, 3, 1, RW, 0x0000, DL_ENABLE_value_map, "Download Enable"), DEFINE_SETTING_ENTRY("START_MICROCNTL", Download_Control, 4, 1, RW, 0x0000, START_MICROCNTL_value_map, "+++VALUE 0 Embedded microcontroller is stopped"), DEFINE_SETTING_ENTRY("MOD_DET_STATUS0", Mode_Detect_Status_0, 0, 8, RO, 0x0000, 0, "Detected audio mode"), DEFINE_SETTING_ENTRY("MOD_DET_STATUS1", Mode_Detect_Status_1, 0, 8, RO, 0x0000, 0, "Detected audio standard"), DEFINE_SETTING_ENTRY("AUD_MODE_AUD_SYSTEM", Audio_Configuration, 0, 4, RW, 0x0000, 0, "Force audio mode:"), DEFINE_SETTING_ENTRY("AUD_STANDARD", Audio_Configuration, 4, 4, RW, 0x0000, 0, "Audio standard"), DEFINE_SETTING_ENTRY("PREF_MODE", Preferred_Decode_Mode, 0, 4, RW, 0x0000, PREF_MODE_value_map, "Note: Not all settings apply to all standards. If PREF_MODE is set to"), DEFINE_SETTING_ENTRY("MUTE_NO_PREF_MODE", Preferred_Decode_Mode, 4, 1, RW, 0x0000, MUTE_NO_PREF_MODE_value_map, "+++VALUE 0 Do not mute output if the preferred mode is not available."), DEFINE_SETTING_ENTRY("DE_EMPHASIS_TIME", Preferred_Decode_Mode, 5, 1, RW, 0x0000, DE_EMPHASIS_TIME_value_map, "+++VALUE 0 75 µs"), DEFINE_SETTING_ENTRY("FM_DEVIATION", Preferred_Decode_Mode, 6, 2, RW, 0x0000, FM_DEVIATION_value_map, "Only applicable for AUD_STANDARD (0x808) = 0x5 or when A2-DK"), DEFINE_SETTING_ENTRY("MICROCNTL_VIDEO_FORMAT", Embedded_Microcontroller_Video_Format, 0, 4, RO, 0x0000, 0, "Detected video format"), DEFINE_SETTING_ENTRY("VIDEO_PRESENT", Embedded_Microcontroller_Video_Format, 4, 1, RO, 0x0000, 0, "Video present signal"), DEFINE_SETTING_ENTRY("FORMAT_45MHZ", Audio_Format_Control_0, 0, 3, RW, 0x0000, FORMAT_45MHZ_value_map, "Only applicable when AUD_MODE/AUD_SYSTEM (0x808) = 0xF"), DEFINE_SETTING_ENTRY("FORMAT_65MHZ", Audio_Format_Control_0, 3, 2, RW, 0x0000, FORMAT_65MHZ_value_map, "Only applicable when AUD_MODE/AUD_SYSTEM (0x808) = 0xF"), DEFINE_SETTING_ENTRY("TUNER_OUTPUT_FORMAT", Audio_Format_Control_0, 5, 1, RW, 0x0000, TUNER_OUTPUT_FORMAT_value_map, "Only applicable when AUD_STANDARD (0x808) = 0x01 or 0xE"), DEFINE_SETTING_ENTRY("SOFT_RESET", Soft_Reset, 0, 1, RW, 0x0000, 0, "Soft reset to ensure smooth transition of operation modes."), DEFINE_SETTING_ENTRY("AC97_INT_DIS", Audio_Interrupt_Control, 0, 1, RW, 0x0001, AC97_INT_DIS_value_map, "0= AC97 interrupt enabled"), DEFINE_SETTING_ENTRY("AMC_INT_DIS", Audio_Interrupt_Control, 1, 1, RW, 0x0001, AMC_INT_DIS_value_map, "+++VALUE 0 Audio mode change interrupt enabled (i.e., mono to stereo, stereo to"), DEFINE_SETTING_ENTRY("FC_INT_DIS", Audio_Interrupt_Control, 2, 1, RW, 0x0001, FC_INT_DIS_value_map, "+++VALUE 0 Audio format change interrupt enabled"), DEFINE_SETTING_ENTRY("FDL_INT_DIS", Audio_Interrupt_Control, 3, 1, RW, 0x0001, FDL_INT_DIS_value_map, "+++VALUE 0 Format detection loop complete interrupt enabled"), DEFINE_SETTING_ENTRY("IFL_INT_DIS", Audio_Interrupt_Control, 4, 1, RW, 0x0001, IFL_INT_DIS_value_map, "+++VALUE 0 IF signal lost interrupt enabled"), DEFINE_SETTING_ENTRY("NLL_INT_DIS", Audio_Interrupt_Control, 5, 1, RW, 0x0001, NLL_INT_DIS_value_map, "+++VALUE 0 NICAM lost lock interrupt enabled"), DEFINE_SETTING_ENTRY("NBER_INT_DIS", Audio_Interrupt_Control, 6, 1, RW, 0x0001, NBER_INT_DIS_value_map, "+++VALUE 0 NICAM bit error rate too high interrupt enabled"), DEFINE_SETTING_ENTRY("RDS_INT_DIS", Audio_Interrupt_Control, 7, 1, RW, 0x0001, RDS_INT_DIS_value_map, "+++VALUE 0 RDS data ready interrupt enabled"), DEFINE_SETTING_ENTRY("AC97_INT", Audio_Interrupt_Status, 0, 1, RO, 0x0000, 0, "+++VALUE 1 AC97 interrupt asserted"), DEFINE_SETTING_ENTRY("AMC_INT", Audio_Interrupt_Status, 1, 1, RO, 0x0000, 0, "+++VALUE 1 Audio mode change interrupt asserted"), DEFINE_SETTING_ENTRY("AFC_INT", Audio_Interrupt_Status, 2, 1, RO, 0x0000, 0, "+++VALUE 1 Audio format change interrupt asserted"), DEFINE_SETTING_ENTRY("FDL_INT", Audio_Interrupt_Status, 3, 1, RO, 0x0000, 0, "+++VALUE 1 Format detection loop complete interrupt asserted"), DEFINE_SETTING_ENTRY("IFL_INT", Audio_Interrupt_Status, 4, 1, RW, 0x0000, 0, "+++VALUE 1 IF signal lost interrupt asserted"), DEFINE_SETTING_ENTRY("NLL_INT", Audio_Interrupt_Status, 5, 1, RO, 0x0000, 0, "+++VALUE 1 NICAM lost lock interrupt asserted"), DEFINE_SETTING_ENTRY("NBER_INT", Audio_Interrupt_Status, 6, 1, RO, 0x0000, 0, "+++VALUE 1 NICAM bit error rate too high interrupt asserted"), DEFINE_SETTING_ENTRY("RDS_INT", Audio_Interrupt_Status, 7, 1, RO, 0x0000, 0, "+++VALUE 1 RDS interrupt asserted"), DEFINE_SETTING_ENTRY("AAGC_HYST1", Analog_AGC_Hysteresis1, 0, 6, RW, 0x0005, 0, "Controls the hysteresis of the AGC so that the value to the VGA"), DEFINE_SETTING_ENTRY("AAGC_HYST2", Analog_AGC_Hysteresis2, 0, 6, RW, 0x0009, 0, "Controls the hysteresis of the AGC so that the value to the VGA"), DEFINE_SETTING_ENTRY("AAGC_TH", Analog_AGC_Control, 0, 6, RW, 0x000e, 0, "Bypass value for the AGC when AAGC_DEFAULT_EN is"), DEFINE_SETTING_ENTRY("AAGC_GAIN_EN", Analog_AGC_Control, 6, 1, RW, 0x0000, AAGC_GAIN_EN_value_map, "Controls the gain of the AGC feedback."), DEFINE_SETTING_ENTRY("AAGC_DEFAULT", AFE_12DB_ENABLE, 0, 6, RW, 0x0020, 0, "Bypass value for the AGC when AAGC_DEFAULT_EN is asserted."), DEFINE_SETTING_ENTRY("AAGC_DEFAULT_EN", AFE_12DB_ENABLE, 6, 1, RW, 0x0000, AAGC_DEFAULT_EN_value_map, "Enables bypass of the AGC."), DEFINE_SETTING_ENTRY("AFE_12DB_EN", AFE_12DB_ENABLE, 7, 1, RW, 0x0000, AFE_12DB_EN_value_map, "Enables a +12 dB gain in the analog front end (AFE). When using"), DEFINE_SETTING_ENTRY("IF_SRC_MODE", IF_SRC_Mode, 0, 1, RW, 0x0000, IF_SRC_MODE_value_map, "Controls IF SRC Decimation filter for different input"), DEFINE_SETTING_ENTRY("PHASE_FIX", Phase_Fix_Control, 0, 4, RW, 0x03e9, 0, "Phase fix delay measured in samples of delay at the"), DEFINE_SETTING_ENTRY("PH_CH_SEL", Phase_Fix_Control, 4, 1, RW, 0x0000, PH_CH_SEL_value_map, "Selects channel to be phase delayed"), DEFINE_SETTING_ENTRY("PH_DBX_SEL", Phase_Fix_Control, 5, 1, RW, 0x0000, 0, "Selects DBX input to be channel 2 when asserted."), DEFINE_SETTING_ENTRY("DEMATRIX_MODE", Dematrix_Bypass, 0, 2, RW, 0x0000, DEMATRIX_MODE_value_map, "+++VALUE 0 Dematrix Sum/Diff"), DEFINE_SETTING_ENTRY("DMTRX_BYPASS", Dematrix_Bypass, 2, 1, RW, 0x0000, DMTRX_BYPASS_value_map, "Dematrix bypass enable bit"), DEFINE_SETTING_ENTRY("DEMATRIX_SEL_CTL", Dematrix_Select_Control, 0, 8, RW, 0x0000, 0, "0x08 = BTSC force mono"), DEFINE_SETTING_ENTRY("SA_IN_SHIFT", Digital_Audio_Input_Shifter, 0, 4, RW, 0x0000, 0, "Serial audio input shift. Signed 2s complement format."), DEFINE_SETTING_ENTRY("AC97_IN_SHIFT", Digital_Audio_Input_Shifter, 4, 4, RW, 0x0000, 0, "AC97 input shift. Signed 2s complement format. Shift"), DEFINE_SETTING_ENTRY("PATH1_SEL_CTL", Path1_Audio_Select_Control, 0, 4, RW, 0x0000, 0, "Source select for the first baseband audio processing"), DEFINE_SETTING_ENTRY("PATH1_AVC_RMS_CON", Path1_Audio_Select_Control, 4, 4, RW, 0x0049, 0, "Define AVC time gain for level detection"), DEFINE_SETTING_ENTRY("PATH1_AVC_CR", Path1_AVC_Control1, 0, 3, RW, 0x0000, PATH1_AVC_CR_value_map, "Define path 1 AVC compression ratio"), DEFINE_SETTING_ENTRY("PATH1_AVC_STEREO", Path1_AVC_Control1, 3, 1, RW, 0x0001, PATH1_AVC_STEREO_value_map, "+++VALUE 0 Independence Mode"), DEFINE_SETTING_ENTRY("PATH1_AVC_AT", Path1_AVC_Control1, 4, 4, RW, 0x0009, PATH1_AVC_AT_value_map, "Define AVC attack time"), DEFINE_SETTING_ENTRY("PATH1_AVC_RT", Path1_AVC_Control2, 0, 4, RW, 0x0048, PATH1_AVC_RT_value_map, "Define AVC release time"), DEFINE_SETTING_ENTRY("PATH1_AVC_CG", Path1_AVC_Control2, 4, 2, RW, 0x0000, PATH1_AVC_CG_value_map, "Define AVC compression gain"), DEFINE_SETTING_ENTRY("SOFT1_MUTE_EN", Mute_Control, 0, 1, RW, 0x0001, SOFT1_MUTE_EN_value_map, "Soft mute enable"), DEFINE_SETTING_ENTRY("SRC1_MUTE_EN", Mute_Control, 1, 1, RW, 0x0000, SRC1_MUTE_EN_value_map, "Source mute enable"), DEFINE_SETTING_ENTRY("SA_MUTE_EN", Mute_Control, 2, 1, RW, 0x0000, SA_MUTE_EN_value_map, "Serial audio mute enable"), DEFINE_SETTING_ENTRY("PAR_MUTE_EN", Mute_Control, 3, 1, RW, 0x0000, PAR_MUTE_EN_value_map, "Ancillary Audio mute enable"), DEFINE_SETTING_ENTRY("AC97_MUTE_EN", Mute_Control, 4, 1, RW, 0x0000, AC97_MUTE_EN_value_map, "AC97 mute"), DEFINE_SETTING_ENTRY("PATH1_VOLUME", Path1_Volume, 0, 8, RW, 0x0024, 0, "Volume control in dB steps. +18 dB to 96 dB in ½ dB"), DEFINE_SETTING_ENTRY("PATH1_BAL_LEVEL", Path1_Balance, 0, 7, RW, 0x0000, 0, "Attenuation to be provided to the selected channel in"), DEFINE_SETTING_ENTRY("PATH1_BAL_LEFT", Path1_Balance, 7, 1, RW, 0x0000, 0, "Select left channel for balance control if 1, select right"), DEFINE_SETTING_ENTRY("PATH1_AVC_THRESH", Path1_AVC_Threshold_Low, 0, 16, RW, 0x7fff, 0, "Define AVC Threshold"), DEFINE_SETTING_ENTRY("PATH1_EQ_BAND_SEL", Path1_EQ_Band_Select, 0, 1, RW, 0x0000, PATH1_EQ_BAND_SEL_value_map, "Equalizer band selection"), DEFINE_SETTING_ENTRY("PATH1_EQ_BASS_VOL", Path1_EQ_Bass_Adjust, 0, 6, RW, 0x0000, 0, "Equalizer Bass Volume control in dB steps."), DEFINE_SETTING_ENTRY("PATH1_EQ_MID_VOL", Path1_EQ_Midrange_Adjust, 0, 6, RW, 0x0000, 0, "Equalizer Mid-tone Volume control in dB steps."), DEFINE_SETTING_ENTRY("PATH1_EQ_TREBLE_VOL", Path1_EQ_Treble_Adjust, 0, 6, RW, 0x0000, 0, "Equalizer Treble Volume control in dB steps."), DEFINE_SETTING_ENTRY("PATH1_SC_RMS_CON", Path1_Soft_Clip_Control1, 0, 4, RW, 0x0009, PATH1_SC_RMS_CON_value_map, "Define SC time gain for level detection"), DEFINE_SETTING_ENTRY("PATH1_SC_CR", Path1_Soft_Clip_Control1, 4, 3, RW, 0x0008, PATH1_SC_CR_value_map, "Define SC compression ratio"), DEFINE_SETTING_ENTRY("PATH1_SC_STEREO", Path1_Soft_Clip_Control1, 7, 1, RW, 0x0000, PATH1_SC_STEREO_value_map, "+++VALUE 0 Independence Mode"), DEFINE_SETTING_ENTRY("PATH1_SC_AT", Path1_Soft_Clip_Control2, 0, 4, RW, 0x0009, PATH1_SC_AT_value_map, "Define SC attack time"), DEFINE_SETTING_ENTRY("PATH1_SC_RT", Path1_Soft_Clip_Control2, 4, 4, RW, 0x0009, PATH1_SC_RT_value_map, "Define SC release time"), DEFINE_SETTING_ENTRY("PATH1_SC_THRESH", Path1_Soft_Clip_Threshold_Low, 0, 16, RW, 0x7fff, 0, "Define Soft Clip Threshold Low Byte"), DEFINE_SETTING_ENTRY("PATH2_SEL_CTL", Path2_Audio_Select_Control, 0, 4, RW, 0x0000, 0, "Source select for the first baseband audio"), DEFINE_SETTING_ENTRY("PATH2_AVC_RMS_CON", Path2_Audio_Select_Control, 4, 4, RW, 0x0049, 0, "Define AVC time gain for level detection"), DEFINE_SETTING_ENTRY("PATH2_AVC_CR", Path2_AVC_Control1, 0, 3, RW, 0x0000, PATH2_AVC_CR_value_map, "Define path 2 AVC compression ratio"), DEFINE_SETTING_ENTRY("PATH2_AVC_STEREO", Path2_AVC_Control1, 3, 1, RW, 0x0001, PATH2_AVC_STEREO_value_map, "+++VALUE 0 Independence Mode"), DEFINE_SETTING_ENTRY("PATH2_AVC_AT", Path2_AVC_Control1, 4, 4, RW, 0x0009, PATH2_AVC_AT_value_map, "Define AVC attack time"), DEFINE_SETTING_ENTRY("PATH2_AVC_RT", Path2_AVC_Control2, 0, 4, RW, 0x0048, PATH2_AVC_RT_value_map, "Define AVC release time"), DEFINE_SETTING_ENTRY("PATH2_AVC_CG", Path2_AVC_Control2, 4, 2, RW, 0x0000, PATH2_AVC_CG_value_map, "Define AVC compression gain"), DEFINE_SETTING_ENTRY("SOFT2_MUTE_EN", Path2_Mute_Control, 0, 1, RW, 0x0001, 0, "Soft mute enable"), DEFINE_SETTING_ENTRY("SRC2_MUTE_EN", Path2_Mute_Control, 1, 1, RW, 0x0000, 0, "Source mute enable"), DEFINE_SETTING_ENTRY("PATH2_VOLUME", Path2_Volume, 0, 8, RW, 0x0024, 0, "Volume control in dB steps. +18 dB to 96 dB in ½ dB steps"), DEFINE_SETTING_ENTRY("PATH2_BAL_LEVEL", Path2_Balance, 0, 7, RW, 0x0000, 0, "Attenuation to be provided to the selected channel in dB."), DEFINE_SETTING_ENTRY("PATH2_BAL_LEFT", Path2_Balance, 7, 1, RW, 0x0000, 0, "Select left channel for balance control if 1, select right"), DEFINE_SETTING_ENTRY("PATH2_AVC_THRESH", Path2_AVC_Threshold_Low, 0, 16, RW, 0x0400, 0, "Define AVC Threshold"), DEFINE_SETTING_ENTRY("PATH2_EQ_BAND_SEL", Path2_EQ_Band_Select, 0, 1, RW, 0x0000, PATH2_EQ_BAND_SEL_value_map, "Equalizer band selection"), DEFINE_SETTING_ENTRY("PATH2_EQ_BASS_VOL", Path2_EQ_Bass_Adjust, 0, 6, RW, 0x0000, 0, "Equalizer Bass Volume control in dB steps."), DEFINE_SETTING_ENTRY("PATH2_EQ_MID_VOL", Path2_EQ_Midrange_Adjust, 0, 6, RW, 0x0000, 0, "Equalizer Mid-tone Volume control in dB steps."), DEFINE_SETTING_ENTRY("PATH2_EQ_TREBLE_VOL", Path2_EQ_Treble_Adjust, 0, 6, RW, 0x0000, 0, "Equalizer Treble Volume control in dB steps."), DEFINE_SETTING_ENTRY("PATH2_SC_RMS_CON", Path2_Soft_Clip_Control1, 0, 4, RW, 0x0009, PATH2_SC_RMS_CON_value_map, "Define SC time gain for level detection"), DEFINE_SETTING_ENTRY("PATH2_SC_CR", Path2_Soft_Clip_Control1, 4, 3, RW, 0x0008, PATH2_SC_CR_value_map, "Define SC compression ratio"), DEFINE_SETTING_ENTRY("PATH2_SC_STEREO", Path2_Soft_Clip_Control1, 7, 1, RW, 0x0000, PATH2_SC_STEREO_value_map, "+++VALUE 0 Independence Mode"), DEFINE_SETTING_ENTRY("PATH2_SC_AT", Path2_Soft_Clip_Control2, 0, 4, RW, 0x0009, PATH2_SC_AT_value_map, "Define SC attack time"), DEFINE_SETTING_ENTRY("PATH2_SC_RT", Path2_Soft_Clip_Control2, 4, 4, RW, 0x0009, PATH2_SC_RT_value_map, "Define SC release time"), DEFINE_SETTING_ENTRY("PATH2_SC_THRESH", Path2_Soft_Clip_Threshold_Low, 0, 16, RW, 0x7fff, 0, "Define Soft Clip Threshold Low Byte"), DEFINE_SETTING_ENTRY("Sample_Rate_Converter_Status1_REG", Sample_Rate_Converter_Status1, 0, 8, RW, 0x0000, 0, "Missing bit spec for reg"), DEFINE_SETTING_ENTRY("Sample_Rate_Converter_Status2_REG", Sample_Rate_Converter_Status2, 0, 8, RW, 0x0000, 0, "Missing bit spec for reg"), DEFINE_SETTING_ENTRY("SRC1_PHASE_INC", SRC1_Phase_Increment_Low, 0, 18, RW, 0x01867c, 0, "Low byte of SRC 1 phase increment value. Calculated by"), DEFINE_SETTING_ENTRY("SRC1_FIFO_RD_TH", SRC1_FIFO_Read_Threshold, 0, 4, RW, 0x0008, 0, "SRC 1 FIFO threshold for Read Enable. Apply to both left"), DEFINE_SETTING_ENTRY("SRC2_PHASE_INC", SRC2_Phase_Increment_Low, 0, 18, RW, 0x01867c, 0, "Low byte of SRC 2 phase increment value. Calculated by"), DEFINE_SETTING_ENTRY("SRC2_FIFO_RD_TH", SRC2_FIFO_Read_Threshold, 0, 4, RW, 0x0008, 0, "SRC 2 FIFO threshold for Read Enable. Apply to both left"), DEFINE_SETTING_ENTRY("SRC3_PHASE_INC", SRC3_Phase_Increment_Low, 0, 18, RW, 0x014faa, 0, "Low byte of SRC 3 phase increment value. Calculated by"), DEFINE_SETTING_ENTRY("SRC3_FIFO_RD_TH", SRC3_FIFO_Read_Threshold, 0, 4, RW, 0x0008, 0, "SRC 3 FIFO threshold for Read Enable. Apply to both left"), DEFINE_SETTING_ENTRY("SRC4_PHASE_INC", SRC4_Phase_Increment_Low, 0, 18, RW, 0x014faa, 0, "Low byte of SRC 4 phase increment value. Calculated by"), DEFINE_SETTING_ENTRY("SRC4_FIFO_RD_TH", SRC4_FIFO_Read_Threshold, 0, 4, RW, 0x0008, 0, "SRC 4 FIFO threshold for Read Enable. Apply to both left"), DEFINE_SETTING_ENTRY("SRC5_PHASE_INC", SRC5_Phase_Increment_Low, 0, 18, RW, 0x010453, 0, "Low byte of SRC 5 phase increment value. Calculated by"), DEFINE_SETTING_ENTRY("SRC5_FIFO_RD_TH", SRC5_FIFO_Read_Threshold, 0, 4, RW, 0x0008, 0, "SRC 5 FIFO threshold for Read Enable. Apply to both left"), DEFINE_SETTING_ENTRY("SRC6_PHASE_INC", SRC6_Phase_Increment_Low, 0, 18, RW, 0x014faa, 0, "Low byte of SRC 6 phase increment value. Calculated by"), DEFINE_SETTING_ENTRY("SRC6_FIFO_RD_TH", SRC6_FIFO_Read_Threshold, 0, 4, RW, 0x0008, 0, "SRC 6 FIFO threshold for Read Enable. Apply to both left"), DEFINE_SETTING_ENTRY("PARALLEL1_SRC_SEL", Output_SRC_Source_Select, 0, 2, RW, 0x0001, PARALLEL1_SRC_SEL_value_map, "Output source select."), DEFINE_SETTING_ENTRY("PARALLEL2_SRC_SEL", Output_SRC_Source_Select, 2, 2, RW, 0x000a, PARALLEL2_SRC_SEL_value_map, "Output source select."), DEFINE_SETTING_ENTRY("SERIAL_AUDIO_SRC_SEL", Output_SRC_Source_Select, 4, 2, RW, 0x0000, SERIAL_AUDIO_SRC_SEL_value_map, "Output source select."), DEFINE_SETTING_ENTRY("AC97_SRC_SEL", Output_SRC_Source_Select, 6, 2, RW, 0x000b, AC97_SRC_SEL_value_map, "Output source select."), DEFINE_SETTING_ENTRY("BASEBAND_BYPASS_CTL", Baseband_Bypass_Control, 0, 8, RW, 0x0000, BASEBAND_BYPASS_CTL_value_map, "Baseband block bypass control"), DEFINE_SETTING_ENTRY("SRC3_CLK_SEL", Input_SRC_Source_Select1, 0, 2, RW, 0x0000, SRC3_CLK_SEL_value_map, "SRC output FIFO read select"), DEFINE_SETTING_ENTRY("SRC3_IN_SEL", Input_SRC_Source_Select1, 2, 2, RW, 0x0000, SRC3_IN_SEL_value_map, "SRC input source select."), DEFINE_SETTING_ENTRY("SRC4_CLK_SEL", Input_SRC_Source_Select1, 4, 2, RW, 0x000b, SRC4_CLK_SEL_value_map, "SRC output FIFO read select"), DEFINE_SETTING_ENTRY("SRC4_IN_SEL", Input_SRC_Source_Select1, 6, 2, RW, 0x000a, SRC4_IN_SEL_value_map, "SRC input source select."), DEFINE_SETTING_ENTRY("SRC5_CLK_SEL", Input_SRC_Source_Select2, 0, 2, RW, 0x000a, SRC5_CLK_SEL_value_map, "SRC output fifo read select"), DEFINE_SETTING_ENTRY("SRC5_IN_SEL", Input_SRC_Source_Select2, 2, 2, RW, 0x0000, SRC5_IN_SEL_value_map, "SRC input source select"), DEFINE_SETTING_ENTRY("SRC6_CLK_SEL", Input_SRC_Source_Select2, 4, 2, RW, 0x0001, SRC6_CLK_SEL_value_map, "SRC output fifo read select"), DEFINE_SETTING_ENTRY("SRC6_IN_SEL", Input_SRC_Source_Select2, 6, 2, RW, 0x0000, SRC6_IN_SEL_value_map, "SRC input source select."), DEFINE_SETTING_ENTRY("SA_IN_BCN_DEL", Serial_Audio_Input_Control1, 0, 5, RW, 0x0000, 0, "Controls a number of SA_BCLK_IN cycles delay for"), DEFINE_SETTING_ENTRY("SA_IN_WS_SEL", Serial_Audio_Input_Control1, 5, 1, RW, 0x0000, SA_IN_WS_SEL_value_map, "Control for Word Select (SA_WCLK_IN) polarity."), DEFINE_SETTING_ENTRY("SA_IN_RIGHT_JUST", Serial_Audio_Input_Control1, 6, 1, RW, 0x0000, SA_IN_RIGHT_JUST_value_map, "+++VALUE 0 Left justified serial data"), DEFINE_SETTING_ENTRY("SA_IN_SONY_MODE", Serial_Audio_Input_Control1, 7, 1, RW, 0x0000, SA_IN_SONY_MODE_value_map, "+++VALUE 0 Philips mode: 2nd SA_BCLK_IN rising edge after"), DEFINE_SETTING_ENTRY("SA_IN_MASTER_MODE", Serial_Audio_Input_Control2, 0, 1, RW, 0x0000, SA_IN_MASTER_MODE_value_map, "+++VALUE 0 Slave operation"), DEFINE_SETTING_ENTRY("SA_UP2X_BYPASS", Serial_Audio_Input_Control2, 1, 1, RW, 0x0000, 0, "Enable bypass mode for greater than 48 kHz sample rate"), DEFINE_SETTING_ENTRY("SA_OUT_BCNT_DEL", Serial_Audio_Output_Control1, 0, 5, RW, 0x0000, 0, "Controls a number of SA_BCLK_OUT cycles delay for"), DEFINE_SETTING_ENTRY("SA_OUT_WS_SEL", Serial_Audio_Output_Control1, 5, 1, RW, 0x0000, SA_OUT_WS_SEL_value_map, "Control for Word Select (SA_WCLK_OUT) polarity."), DEFINE_SETTING_ENTRY("SA_OUT_RIGHT_JUST", Serial_Audio_Output_Control1, 6, 1, RW, 0x0000, SA_OUT_RIGHT_JUST_value_map, "+++VALUE 0 Left justified serial data"), DEFINE_SETTING_ENTRY("SA_OUT_SONY_MODE", Serial_Audio_Output_Control1, 7, 1, RW, 0x0000, SA_OUT_SONY_MODE_value_map, "+++VALUE 0 Philips mode: 2nd SA_BCLK_OUT rising edge after"), DEFINE_SETTING_ENTRY("SA_OUT_MASTER_MODE", Serial_Audio_Output_Control2, 0, 1, RW, 0x0000, SA_OUT_MASTER_MODE_value_map, "+++VALUE 0 Slave operation"), DEFINE_SETTING_ENTRY("AC97_SHUTDOWN", AC97_Shutdown, 0, 1, RW, 0x0000, 0, "Disable the AC97 interface"), DEFINE_SETTING_ENTRY("AC97_WAKE_UP_SYNC", AC97_Wake_Up, 0, 1, RW, 0x0000, 0, "Wake up the AC97 interface from sleep mode"), DEFINE_SETTING_ENTRY("AC97_RST_ACL", AC97_Reset, 0, 1, RW, 0x0000, 0, "Reset the AC97 interface"), DEFINE_SETTING_ENTRY("AC97_UP2X_BYPASS", AC97_Upsample_Bypass, 0, 1, RW, 0x0000, AC97_UP2X_BYPASS_value_map, "+++VALUE 0 Normal operation"), DEFINE_SETTING_ENTRY("ACLMSTR_BIT1", ACL_Control_0, 1, 1, RW, 0x0000, ACLMSTR_BIT1_value_map, "AC_LINK Mode:"), DEFINE_SETTING_ENTRY("ACLMSTR_4TO2_3_2_", ACL_Control_0, 2, 2, RW, 0x0000, ACLMSTR_4TO2_3_2__value_map, "GPIO Input Interrupt Control:"), DEFINE_SETTING_ENTRY("ACLMSTR_4TO2_4_", ACL_Control_0, 4, 1, RW, 0x0000, ACLMSTR_4TO2_4__value_map, "GPIO Output Interrupt Control:"), DEFINE_SETTING_ENTRY("ACLMSTR_12TO8_8__", ACL_Control_0, 7, 2, RW, 0x0000, ACLMSTR_12TO8_8___value_map, ""), DEFINE_SETTING_ENTRY("ACLMSTR_12TO8_9_", ACL_Control_0, 9, 1, RW, 0x0000, ACLMSTR_12TO8_9__value_map, "Command Output Interrupt Control:"), DEFINE_SETTING_ENTRY("ACLMSTR_12TO8_10_", ACL_Control_0, 10, 1, RW, 0x0000, ACLMSTR_12TO8_10__value_map, "Tag Arrival Interrupt Control:"), DEFINE_SETTING_ENTRY("ACLMSTR_12TO8_11_", ACL_Control_0, 16, 1, RC, 0x0000, 0, "GPIO Input Interrupt Status"), DEFINE_SETTING_ENTRY("ACLMSTR_12TO8_12_", ACL_Control_0, 17, 1, RC, 0x0000, 0, "GPIO Output Interrupt Status"), DEFINE_SETTING_ENTRY("ACLMSTR_16TO14_14_", ACL_Control_0, 19, 1, RC, 0x0000, 0, "Slot 1 / 2 Status Input Interrupt Status"), DEFINE_SETTING_ENTRY("ACLMSTR_16TO14_15_", ACL_Control_0, 20, 1, RC, 0x0000, 0, "Command Output Interrupt Status"), DEFINE_SETTING_ENTRY("ACLMSTR_16TO14_16_", ACL_Control_0, 21, 1, RC, 0x0000, 0, "Tag Arrival Interrupt Status"), DEFINE_SETTING_ENTRY("ACLCTRL00", ACL_Control_0, 24, 1, RW, 0x0000, 0, "LBUS Source Target ACL00 (Primary Audio Record)"), DEFINE_SETTING_ENTRY("ACLCTRL01_1_0_", ACL_Control_1, 0, 2, RW, 0x0000, ACLCTRL01_1_0__value_map, "ACL01 Format/Enable:"), DEFINE_SETTING_ENTRY("ACLCTRL02_1_0_", ACL_Control_1, 8, 2, RW, 0x0000, ACLCTRL02_1_0__value_map, "ACL02 Format/Enable:"), DEFINE_SETTING_ENTRY("ACLCTRL03_1_0_", ACL_Control_1, 16, 2, RW, 0x0000, ACLCTRL03_1_0__value_map, "ACL03 Format/Enable:"), DEFINE_SETTING_ENTRY("ACLCTRL04_1_0_", ACL_Control_1, 24, 2, RW, 0x0000, ACLCTRL04_1_0__value_map, "ACL04 Format/Enable:"), DEFINE_SETTING_ENTRY("ACLCTRL05_5_0_", ACL_Control_2, 8, 6, RW, 0x003f, 0, "ACL05 Target ID: 0x3F = Disable"), DEFINE_SETTING_ENTRY("ACLCTRL06_1_0_", ACL_Control_2, 16, 2, RW, 0x0000, ACLCTRL06_1_0__value_map, "ACL06 Format/Enable:"), DEFINE_SETTING_ENTRY("ACLCTRL06_7_2_", ACL_Control_2, 24, 6, RW, 0x003f, 0, "ACL06 Target ID: 0x3F = Disable"), DEFINE_SETTING_ENTRY("ACLCTRL07_1_0_", ACL_Control_3, 0, 2, RW, 0x0000, ACLCTRL07_1_0__value_map, "ACL07 Format/Enable:"), DEFINE_SETTING_ENTRY("ACLCTRL07_7_2_", ACL_Control_3, 8, 6, RW, 0x003f, 0, "ACL07 Target ID: 0x3F = Disable"), DEFINE_SETTING_ENTRY("ACLCTRL08_1_0_", ACL_Control_3, 16, 2, RW, 0x0000, ACLCTRL08_1_0__value_map, "ACL08 Format/Enable:"), DEFINE_SETTING_ENTRY("ACLCTRL08_7_2_", ACL_Control_3, 24, 6, RW, 0x003f, 0, "ACL08 Target ID: 0x3f = Disable"), DEFINE_SETTING_ENTRY("ACLCMD_15_0_", ACL_Command, 0, 16, RW, 0x0000, 0, "Command Data"), DEFINE_SETTING_ENTRY("ACLCMD_23_16_", ACL_Command, 16, 8, RW, 0x0000, 0, "Command Address"), DEFINE_SETTING_ENTRY("ACLGPOUT_15_0_", ACL_GPIO_Output_Data, 0, 16, RW, 0x0000, 0, "GPIO Output Data"), DEFINE_SETTING_ENTRY("ACLGPIN_15_0_", ACL_GPIO_Input_Data, 0, 16, RW, 0x0000, 0, "GPIO Input Data"), DEFINE_SETTING_ENTRY("ACLSTAT0_15_0_", ACL_Status_Slot_Interface, 0, 16, RW, 0x0000, 0, "Status DataThis register contains the most recent"), DEFINE_SETTING_ENTRY("ACLSTAT0_23_16_", ACL_Status_Slot_Interface, 16, 8, RW, 0x0000, 0, "Status Address"), DEFINE_SETTING_ENTRY("LOWPOWER_0_", ACL_Warm_Reset, 0, 1, RW, 0x0000, 0, "Clock Source Selector: Clock source for Reset Counter"), DEFINE_SETTING_ENTRY("LOWPOWER_7_1_", ACL_Warm_Reset, 1, 7, RW, 0x0000, 0, "Sync Pulse Counter: Number of cycles for which Sync is"), DEFINE_SETTING_ENTRY("LOWPOWER_20_8_", ACL_Warm_Reset, 8, 13, RW, 0x0000, 0, "Reset Counter: Number of cycles for which AC_LINK"), DEFINE_SETTING_ENTRY("ACL_TAG", ACL_Tag, 3, 12, RO, 0x0000, 0, "Missing bit spec for reg"), DEFINE_SETTING_ENTRY("ACL_LINK_UPDATE", ACL_Tag, 31, 1, RO, 0x0000, 0, "Missing bit spec for reg"), DEFINE_SETTING_ENTRY("RDS_I", RDS_I_Low, 0, 16, RO, 0x0000, 0, "Low byte of RDS_I. RDS I output.") }; ivtv-utils-1.4.1/utils/cx25840ctl/cx25840ctl.10000664000076400007640000000115511355717527017026 0ustar andyandy.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36. .TH CX25840CTL "1" "November 2005" "cx25840ctl 1.0" "User Commands" .SH NAME cx25840ctl \- manual page for cx25840ctl 1.0 .SH SYNOPSIS .B cx25840ctl [\fIOPTIONS\fR]... [\fIFILES\fR]... .SH DESCRIPTION cx25840ctl 1.0 .PP Set and list registers on a CX25840 chip via i2c\-dev .TP \fB\-h\fR, \fB\-\-help\fR Print help and exit .TP \fB\-V\fR, \fB\-\-version\fR Print version and exit .TP \fB\-l\fR, \fB\-\-list\-registers\fR dump CX25840 settings to stdout (default=off) .TP \fB\-s\fR, \fB\-\-set\-registers\fR read CX25840 settings from stdin (default=off) ivtv-utils-1.4.1/utils/cx25840ctl/cmdline.h0000664000076400007640000000314211355717527017006 0ustar andyandy/* cmdline.h */ /* File autogenerated by gengetopt version 2.14 */ #ifndef CMDLINE_H #define CMDLINE_H /* If we use autoconf. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #ifndef CMDLINE_PARSER_PACKAGE #define CMDLINE_PARSER_PACKAGE "cx25840ctl" #endif #ifndef CMDLINE_PARSER_VERSION #define CMDLINE_PARSER_VERSION "1.0" #endif struct gengetopt_args_info { int list_registers_flag; /* dump CX25840 settings to stdout (default=off). */ int set_registers_flag; /* read CX25840 settings from stdin (default=off). */ int help_given ; /* Whether help was given. */ int version_given ; /* Whether version was given. */ int list_registers_given ; /* Whether list-registers was given. */ int set_registers_given ; /* Whether set-registers was given. */ char **inputs ; /* unamed options */ unsigned inputs_num ; /* unamed options number */ } ; int cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info); int cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required); int cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info); void cmdline_parser_print_help(void); void cmdline_parser_print_version(void); void cmdline_parser_init (struct gengetopt_args_info *args_info); void cmdline_parser_free (struct gengetopt_args_info *args_info); int cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* CMDLINE_H */ ivtv-utils-1.4.1/utils/cx25840ctl/cx25840ctl.c0000664000076400007640000001310711355717527017110 0ustar andyandy/* cx25840ctl - Set and list registers on a CX25840 chip via i2c-dev * * Copyright (C) 2005 Jelte van der Hoek. * * Extensively modified by Tyler Trafford * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include #include #include #include #include #include "i2c-dev.h" #include "cmdline.h" #include "cx25840-registers.h" static inline int cx25840_write(int fd, __u16 addr, __u8 value); static inline __u8 cx25840_read(int fd, __u16 addr); static inline void write_setting(int fd, __u16 setting, __u32 value); static inline __u32 read_setting(int fd, __u16 setting); static inline void set_registers(int fd); static inline void list_registers(FILE *output, int fd); int main(int argc, char **argv) { struct gengetopt_args_info opt; char device[20] = "\0"; char sysfile[50] = "\0"; char name[10] = "\0"; int address = 0x44; int fd = -1; FILE *fp, *output; char *pager = "less"; cmdline_parser(argc, argv, &opt); if (opt.inputs_num == 0) { cmdline_parser_print_help(); return 0; } sprintf(device, "/dev/i2c-%s", opt.inputs[0]); // open the device if ((fd = open(device, O_RDWR)) < 0) { fprintf(stderr, "Failed to open %s: %s\n", device, strerror(errno)); exit(1); } sprintf(sysfile, "/sys/bus/i2c/devices/%s-%04x/name", opt.inputs[0], address); if ((fp = fopen(sysfile, "r")) != NULL) { fgets(name, sizeof(name), fp); fclose(fp); } if (strncmp(name, "cx25840", 7) != 0) { fprintf(stderr, "i2c-%s @ 0x%x is not a cx25840\n", opt.inputs[0], address); close(fd); exit(1); } if (ioctl(fd, I2C_SLAVE_FORCE, address) < 0) { fprintf(stderr, "Error: Could not set address to 0x%x: %s\n", address, strerror(errno)); exit(1); } if (opt.list_registers_given) { if (!(pager = getenv("PAGER"))) pager = "less"; if (!(output = popen(pager, "w"))) list_registers(stdout, fd); else { list_registers(output, fd); pclose(output); } } if (opt.set_registers_given) set_registers(fd); // close the device close(fd); return 0; } static inline int cx25840_write(int fd, __u16 addr, __u8 value) { __u8 buffer[3]; buffer[0] = addr >> 8; buffer[1] = addr & 0xff; buffer[2] = value; return write(fd, buffer, 3); } static inline __u8 cx25840_read(int fd, __u16 addr) { __u8 buffer[2]; buffer[0] = addr >> 8; buffer[1] = addr & 0xff; if (write(fd, buffer, 2) < 2) return 0; if (read(fd, buffer, 1) < 1) return 0; return buffer[0]; } static inline void write_setting(int fd, __u16 setting, __u32 value) { __u16 addr = CX25840_REGISTER_ADDRESS(CX25840_SETTING_REGISTER_INDEX(setting)); int s = CX25840_SETTING_START_BIT(setting); int l = CX25840_SETTING_BIT_LENGTH(setting); __u8 byte, mask; while (l > 0) { if (s == 0 && l >= 8) byte = value; // just get the low byte else { mask = (0xff >> (8 - (l > 8 ? 8 : l))) << s; byte = cx25840_read(fd, addr) & ~mask; byte |= (value << s) & mask; } cx25840_write(fd, addr++, byte); l -= 8 - s; value >>= 8 - s; s = 0; } } static inline __u32 read_setting(int fd, __u16 setting) { __u16 addr = CX25840_REGISTER_ADDRESS(CX25840_SETTING_REGISTER_INDEX(setting)); int s = CX25840_SETTING_START_BIT(setting); int l = CX25840_SETTING_BIT_LENGTH(setting); int rl = (s + l + 7) / 8, i = 0; __u32 value = 0; while (rl-- > 0) value |= cx25840_read(fd, addr++) << (i++ * 8); return (value >> s) & (0xffffffff >> (32 - l)); } static inline void list_registers(FILE *output, int fd) { __u32 index, value; for (index = 0; index < number_of_settings; index++) { value_map *ap = CX25840_SETTING_MAPPING(index); char *name = "\0"; value = read_setting(fd, index); while (ap != NULL && ap->name != NULL) { if (ap->value == value) { name = ap->name; break; } ap++; } if (*name) { fprintf(output, "%s=%d (0x%X) \"%s\"\n", CX25840_SETTING_NAME(index), value, value, name); } else { fprintf(output, "%s=%d (0x%X)\n", CX25840_SETTING_NAME(index), value, value); } } } static inline void set_registers(int fd) { FILE *fp = stdin; char buf[512]; char *name, *eq; __u32 index; while (fgets(buf, sizeof(buf) - 1, fp) != NULL) { name = buf; // skip whitespace while (*name == '\t' || *name == ' ') name++; // ignore empty lines if (*name == '\0' || *name == '\n' || *name == '/') continue; // truncate the "C" macro syntax if (strncmp(name, "CX25840_SET_", 12) == 0) name += 12; // find equals as well as '(' eq = strpbrk(name, "=("); if (eq == NULL) { fprintf(stderr, "Syntax error: use ['CX25840_SET_']('('|'='): Ignoring %s\n", buf); continue; } *eq++ = '\0'; for (index = 0; index < number_of_settings; index++) { if (strcmp(name, CX25840_SETTING_NAME(index)) == 0) break; } if (index >= number_of_settings) continue; write_setting(fd, index, strtol(eq, &eq, 0)); } } ivtv-utils-1.4.1/utils/cx25840ctl/cx25840-settings.h0000664000076400007640000002426411355717527020256 0ustar andyandy/* * cx25840 - register map * * This file is auto generated do not edit. * * There are non obvoius relationships between values. * * Submit errors in this file to the ivtv development mail list. * */ #ifndef __CX25840_SETTINGS_H #define __CX25840_SETTINGS_H typedef enum { SLEEP, DIGITAL_PWR_DN, REF_CLK_SEL, PWR_DN_VID_PLL, PWR_DN_AUX_PLL, AUTO_INC_DIS, SLV_SI_DIS, FORCE_CHIP_SEL_VIPCLK, PREFETCH_EN, PWR_DN_PLL_REG1, PWR_DN_PLL_REG2, DEVICE_ID, SOFT_RST, CH_SEL_ADC2, DUAL_MODE_ADC2, CHIP_ACFG_DIS, CH_1__SOURCE, CH_2__SOURCE, CH_3__SOURCE, EN_12DB_CH1, EN_12DB_CH2, EN_12DB_CH3, HALF_BW_CH1, HALF_BW_CH2, HALF_BW_CH3, VGA_SEL_CH1, VGA_SEL_CH2, VGA_SEL_CH3, CLAMP_SEL_CH1, CLAMP_SEL_CH2, CLAMP_SEL_CH3, CHROMA_IN_SEL, LUMA_IN_SEL, AUD_IN_SEL, CLAMP_EN_CH1, CLAMP_EN_CH2, CLAMP_EN_CH3, DROOP_COMP_CH1, DROOP_COMP_CH2, DROOP_COMP_CH3, BYPASS_CH1, BYPASS_CH2, BYPASS_CH3, IREF_SEL, VID_PLL_INT, VID_PLL_POST, AUX_PLL_INT, AUX_PLL_POST, VID_PLL_FRAC1, VID_PLL_FRAC2, VID_PLL_FRAC3, VID_PLL_FRAC4, AUX_PLL_FRAC1, AUX_PLL_FRAC2, AUX_PLL_FRAC3, AUX_PLL_FRAC4, GPIO0_OUT_EN, GPIO1_OUT_EN, CHIP_SEL_VIPCLK_OUT_EN, IRQN_OUT_EN, IR_RX_OUT_EN, IR_TX_OUT_EN, DVALID_OUT_EN, FIELD_OUT_EN, HRESET_OUT_EN, VRESET_OUT_EN, VID_OUT_EN, PIXCLK_OUT_EN, SA_SDIN_OUT_EN, SA_BCLKIN_OUT_EN, SA_WCLKIN_OUT_EN, SA_SDOUT_OUT_EN, SA_BCLKOUT_OUT_EN, SA_WCLKOUT_OUT_EN, PLL_CLK_OUT_EN, AC_OUT_OUT_EN, AC_IN_OUT_EN, IRQ_N_PRGM4, VID_IRQ_STAT, IR_IRQ_STAT, VID_OUT_SPD, VID_CTRL_SPD, AC_OUT_SPD, SA_OUT_SPD, GEN_OUT_SPD, GPIO0_OUT_SEL, GPIO1_OUT_SEL, CHIPSEL_OUT_SEL, IRQN_OUT_SEL, IR_RX_OUT_SEL, IR_TX_OUT_SEL, DVALID_PRGM0_OUT_SEL, FIELD_PRGM1_OUT_SEL, HRESET_PRGM2_OUT_SEL, VRESET_HCTL_PRGM3_OUT_SEL, VID_DATA_OUT_SEL, PIXCLK_OUT_SEL, AC_OUT_SEL, SA_OUT_OUT_SEL, SA_IN_OUT_SEL, AUX_PLL_AOUT_SEL, AUX_PLL_DOUT_SEL, AC_BITCLK_IN_SEL, AC_SDIN_IN_SEL, GPI0_IN_SEL, GPI1_IN_SEL, GPI2_IN_SEL, GPI3_IN_SEL, GPO_OUT, GPI_IN, SA_MCLK_DIV, SA_MCLK_SEL, VID_COUNT, EN_AV_LOCK, AUD_LOCK_KD_SHIFT, AUD_LOCK_KI_SHIFT, AUD_COUNT, AUD_LOCK_FREQ_SHIFT, AUD_LOCK_KD_MULT, AUD_LOCK_KI_MULT, PWR_DN_TUNING, PWR_DN_DLL1, PWR_DN_DLL2, PWR_DN_ADC1, PWR_DN_ADC2, PWR_DN_CH1, PWR_DN_CH2, PWR_DN_CH3, SLEEP_ANALOG_MSK, SLEEP_DLL_MSK, SLEEP_PLL_MSK, VCLK_GATE_MSK, CLK5x_GATE_MSK, SCLK_GATE_MSK, FOUR_X_CLK_ADC, VREG_D_1_0_, VREF_CTRL_ADC, BIAS_CTRL_ADC_1_0_, BIAS_CTRL_ADC_2_, BIAS_CTRL_ADC_4_3_, BIAS_CTRL_ADC_6_5_, S2DIFF_BIAS_1_0_, FILTER_BIAS_1_0_, TUNE_FIL_RST, CH_SEL_ADC1, DISCONNECT_CH1, TEST_MODE_CH1, TUNE_IN_4_0_, FORCE_TUNING, TUNE_OUT, TUNING_READY, VID_DUAL_FLAG_POL, AUD_DUAL_FLAG_POL, PLL_SPMP, VID_PLL_DDS, AUX_PLL_DDS, VID_PLL_RST, AUX_PLL_RST, AUX_PLL_LOCK, VID_PLL_LOCK, AUX_PLL_UNLOCK, VID_PLL_UNLOCK, DLL1_FLD, DLL1_UP_OVRD, DLL1_DOWN_OVRD, DLL1_CHPREF, DLL1_COMP_GT, DLL1_COMP_LT, DLL1_DEPTH, DLL1_DLYS, DLL1_CURRSET, DLL1_BYPASS, DLL2_Diagnostic_Control_1_REG, DLL2_FLD, DLL2_UP_OVRD, DLL2_DOWN_OVRD, DLL2_CHPREF, DLL2_COMP_GT, DLL2_COMP_LT, DLL2_DEPTH, DLL2_DLYS, DLL2_CURRSET, DLL2_BYPASS, WIN, EDG, DMD, MOD, RFE, TFE, RXE, TXE, RIC, TIC, CPL, LBM, R, TCD, RCD, CDC, RTO, ROR, TBY, RSR, TSR, ROE, RSE, TSE, LPF, RX_TX_FIFO, RX_TX_LVL, RXNDV, VID_FMT_SEL, SQ_PIXEL, ACFG_DIS, AFD_PAL_SEL, AFD_NTSC_SEL, AFD_ACQUIRE, INPUT_MODE, MAN_SC_FAST_LOCK, AUTO_SC_LOCK, CKILLEN, CAGCEN, WCEN, FAST_LOCK_MD, CLR_LOCK_STAT, COMB_NOTCH_MODE, CKILL_MODE, AFD_PALM_SEL, AFD_FORCE_PAL, AFD_FORCE_PALNC, AFD_FORCE_SECAM, AFD_PAL60_DIS, OUT_MODE, MODE10B, VBIHACTRAW_EN, ANC_DATA_EN, TASKBIT_VAL, BLUE_FIELD_ACT, BLUE_FIELD_EN, CLAMPRAW_EN, SWAPRAW, ACTFMT, VALIDFMT, HSFMT, CLK_INVERT, CLK_GATING, DCMODE, IDID0_SOURCE, VIP_OPT_AL, VIPBLANK_EN, VIPCLAMP_EN, POLAR, IDID0_9_2__LOW, IDID1_9_2__LOW, IDID0_1_0__HIGH, IDID1_1_0__HIGH, EN_A, EN_B, EN_C, AUD_ANC_EN, SAMPLE_RATE, AUD_GRP, MV_CDAT, MV_PSP, MV_CS, MV_T3CS, MV_TYPE2_PAIR, AFD_FMT_STAT, FIELD, SRC_FIFO_OFLOW, SRC_FIFO_UFLOW, VSYNC, HLOCK, SRC_LOCK, VLOCK, CSC_LOCK, AGC_LOCK, VPRES, SPECIAL_PLAY_N, SRC_FIFO_OFLOW_STAT, SRC_FIFO_UFLOW_STAT, CSC_LOCK_CHANGE_STAT, VLOCK_CHANGE_STAT, HLOCK_CHANGE_STAT, VSYNC_TRAIL_STAT, FMT_CHANGE_STAT, END_VBI_ODD_STAT, END_VBI_EVEN_STAT, MV_CHANGE_STAT, VPRES_CHANGE_STAT, CC_DAT_AVAIL_STAT, GS1_DAT_AVAIL_STAT, GS2_DAT_AVAIL_STAT, WSS_DAT_AVAIL_STAT, SRC_FIFO_OFLOW_MSK, SRC_FIFO_UFLOW_MSK, CSC_LOCK_CHANGE_MSK, VLOCK_CHANGE_MSK, HLOCK_CHANGE_MSK, VSYNC_TRAIL_MSK, FMT_CHANGE_MSK, END_VBI_ODD_MSK, END_VBI_EVEN_MSK, MV_CHANGE_MSK, VPRES_CHANGE_MSK, CC_DAT_AVAIL_MSK, GS1_DAT_AVAIL_MSK, GS2_DAT_AVAIL_MSK, WSS_DAT_AVAIL_MSK, BRIGHT, CNTRST, PEAK_SEL, PEAK_EN, RANGE, LUMA_CORE_SEL, HSCALE, HFILT, VSCALE, VFILT, VS_INTRLACE, LINE_AVG_DIS, USAT, VSAT, HUE, C_CORE_SEL, CHR_DELAY, VBI_MD_LINE1, VBI_MD_LINE2, VBI_MD_LINE3, VBI_MD_LINE4, VBI_MD_LINE5, VBI_MD_LINE6, VBI_MD_LINE7, VBI_MD_LINE8, VBI_MD_LINE9, VBI_MD_LINE10, VBI_MD_LINE11, VBI_MD_LINE12, VBI_MD_LINE13, VBI_MD_LINE14, VBI_MD_LINE15, VBI_MD_LINE16, VBI_MD_LINE17, FC_SEARCH_MODE, FC_ALT1_TYPE, FC_ALT2_TYPE, FC_ALT1, FC_ALT2, ADAPT_SLICE_DIS, EDGE_RESYNC_EN, CRI_MARG_SCALE, VPS_DEC_DIS, MOJI_PACK_DIS, TTX_PKTADRL_LB, TTX_PKTADRL_HN, TTX_PKTADRU_LN, TTX_PKTADRU_HB, VBI1_SDID, VBI2_SDID, VBI3_SDID, CC_FIFO_RST, GS1_FIFO_RST, GS2_FIFO_RST, WSS_FIFO_RST, HAMMING_TYPE, CC_STAT, CC_FIFO_DAT, GS1_STAT, GS1_FIFO_DAT, GS2_STAT, GS2_FIFO_DAT, WSS_STAT, WSS_FIFO_DAT, VBI1_HDELAY, VBI1_BITINC, VBI1_SLICE_DIST, VBI1_CRWIN, VBI1_FRAME_CODE, VBI1_FC_LENGTH, VBI1_CRI_TIME, VBI1_CRI_MARGIN, VBI1_CRI_LENGTH, VBI1_PAYLD_LENGTH, VBI1_FORMAT_TYPE, VBI1_FIFO_MODE, VBI1_HAM_EN, VBI2_HDELAY, VBI2_BITINC, VBI2_SLICE_DIST, VBI1_CRIWIN, VBI2_FRAME_CODE, VBI2_FC_LENGTH, VBI2_CRI_TIME, VBI2_CRI_MARGIN, VBI2_CRI_LENGTH, VBI2_PAYLD_LENGTH, VBI2_FORMAT_TYPE, VBI2_FIFO_MODE, VBI2_HAM_EN, VBI3_HDELAY, VBI3_BITINC, VBI3_SLICE_DIST, VBI3_CRWIN, VBI3_FRAME_CODE, VBI3_FC_LENGTH, VBI3_CRI_TIME, VBI3_CRI_MARGIN, VBI3_CRI_LENGTH, VBI3_PAYLD_LENGTH, VBI3_FORMAT_TYPE, VBI3_FIFO_MODE, VBI3_HAM_EN, HBLANK_CNT, HACTIVE_CNT, BGDEL_CNT, VBLANK_CNT, VACTIVE_CNT, V656BLANK_CNT, SRC_DECIM_RATIO, UV_LPF_SEL, LUMA_LPF_SEL, LCOMB_2LN_EN, LCOMB_3LN_EN, CCOMB_2LN_EN, CCOMB_3LN_EN, SC_STEP, VBI_OFFSET, FIELD_COUNT, TEMPDEC, TDFIELD, TDALGN, HR32, VPRES_VERT_EN, VT_LINE_CNT_HYST, DEBOUNCE_COUNT, VGA_GAIN, AGC_GAIN, CLAMP_LEVEL, VBI_GATE_EN, VGA_AUTO_EN, VGA_CRUSH_EN, AGC_AUTO_EN, CLAMP_AUTO_EN, VGA_SYNC, VGA_TRACK_RANGE, VGA_ACQUIRE_RANGE, DCC_LOOP_GAIN, AGC_LOOP_GAIN, SYNC_LOOP_GAIN, BP_LOOP_GAIN, DFT_THRESHOLD, BP_PERCENT, PLL_MAX_OFFSET, PLL_KI, PLL_KD, HTL_KI, HTL_KD, LCOMB_ERR_LIMIT, LUMA_THRESHOLD, CCOMB_ERR_LIMIT, COMB_PHASE_LIMIT, SYNC_TIP_INC, SYNC_TIP_REDUCE, MAJ_SEL, MAJ_SEL_EN, CRUSH_FREQ, WTW_EN, DFE_RST_MSK, SRC_RST_MSK, YCSEP_RST_MSK, VTG_RST_MSK, LUMA_RST_MSK, CHROMA_RST_MSK, SCALE_RST_MSK, VBI_RST_MSK, MVDET_RST_MSK, VOF_RST_MSK, REG_RST_MSK, VD_SOFT_RST, REV_ID, APL_DETECT_ENA, DL_ADDR_LB, DL_ADDR_HB, DL_DATA_CTL, DL_MAP, DL_AUTO_INC, DL_ENABLE, START_MICROCNTL, MOD_DET_STATUS0, MOD_DET_STATUS1, AUD_MODE_AUD_SYSTEM, AUD_STANDARD, PREF_MODE, MUTE_NO_PREF_MODE, DE_EMPHASIS_TIME, FM_DEVIATION, MICROCNTL_VIDEO_FORMAT, VIDEO_PRESENT, FORMAT_45MHZ, FORMAT_65MHZ, TUNER_OUTPUT_FORMAT, SOFT_RESET, AC97_INT_DIS, AMC_INT_DIS, FC_INT_DIS, FDL_INT_DIS, IFL_INT_DIS, NLL_INT_DIS, NBER_INT_DIS, RDS_INT_DIS, AC97_INT, AMC_INT, AFC_INT, FDL_INT, IFL_INT, NLL_INT, NBER_INT, RDS_INT, AAGC_HYST1, AAGC_HYST2, AAGC_TH, AAGC_GAIN_EN, AAGC_DEFAULT, AAGC_DEFAULT_EN, AFE_12DB_EN, IF_SRC_MODE, PHASE_FIX, PH_CH_SEL, PH_DBX_SEL, DEMATRIX_MODE, DMTRX_BYPASS, DEMATRIX_SEL_CTL, SA_IN_SHIFT, AC97_IN_SHIFT, PATH1_SEL_CTL, PATH1_AVC_RMS_CON, PATH1_AVC_CR, PATH1_AVC_STEREO, PATH1_AVC_AT, PATH1_AVC_RT, PATH1_AVC_CG, SOFT1_MUTE_EN, SRC1_MUTE_EN, SA_MUTE_EN, PAR_MUTE_EN, AC97_MUTE_EN, PATH1_VOLUME, PATH1_BAL_LEVEL, PATH1_BAL_LEFT, PATH1_AVC_THRESH, PATH1_EQ_BAND_SEL, PATH1_EQ_BASS_VOL, PATH1_EQ_MID_VOL, PATH1_EQ_TREBLE_VOL, PATH1_SC_RMS_CON, PATH1_SC_CR, PATH1_SC_STEREO, PATH1_SC_AT, PATH1_SC_RT, PATH1_SC_THRESH, PATH2_SEL_CTL, PATH2_AVC_RMS_CON, PATH2_AVC_CR, PATH2_AVC_STEREO, PATH2_AVC_AT, PATH2_AVC_RT, PATH2_AVC_CG, SOFT2_MUTE_EN, SRC2_MUTE_EN, PATH2_VOLUME, PATH2_BAL_LEVEL, PATH2_BAL_LEFT, PATH2_AVC_THRESH, PATH2_EQ_BAND_SEL, PATH2_EQ_BASS_VOL, PATH2_EQ_MID_VOL, PATH2_EQ_TREBLE_VOL, PATH2_SC_RMS_CON, PATH2_SC_CR, PATH2_SC_STEREO, PATH2_SC_AT, PATH2_SC_RT, PATH2_SC_THRESH, Sample_Rate_Converter_Status1_REG, Sample_Rate_Converter_Status2_REG, SRC1_PHASE_INC, SRC1_FIFO_RD_TH, SRC2_PHASE_INC, SRC2_FIFO_RD_TH, SRC3_PHASE_INC, SRC3_FIFO_RD_TH, SRC4_PHASE_INC, SRC4_FIFO_RD_TH, SRC5_PHASE_INC, SRC5_FIFO_RD_TH, SRC6_PHASE_INC, SRC6_FIFO_RD_TH, PARALLEL1_SRC_SEL, PARALLEL2_SRC_SEL, SERIAL_AUDIO_SRC_SEL, AC97_SRC_SEL, BASEBAND_BYPASS_CTL, SRC3_CLK_SEL, SRC3_IN_SEL, SRC4_CLK_SEL, SRC4_IN_SEL, SRC5_CLK_SEL, SRC5_IN_SEL, SRC6_CLK_SEL, SRC6_IN_SEL, SA_IN_BCN_DEL, SA_IN_WS_SEL, SA_IN_RIGHT_JUST, SA_IN_SONY_MODE, SA_IN_MASTER_MODE, SA_UP2X_BYPASS, SA_OUT_BCNT_DEL, SA_OUT_WS_SEL, SA_OUT_RIGHT_JUST, SA_OUT_SONY_MODE, SA_OUT_MASTER_MODE, AC97_SHUTDOWN, AC97_WAKE_UP_SYNC, AC97_RST_ACL, AC97_UP2X_BYPASS, ACLMSTR_BIT1, ACLMSTR_4TO2_3_2_, ACLMSTR_4TO2_4_, ACLMSTR_12TO8_8__, ACLMSTR_12TO8_9_, ACLMSTR_12TO8_10_, ACLMSTR_12TO8_11_, ACLMSTR_12TO8_12_, ACLMSTR_16TO14_14_, ACLMSTR_16TO14_15_, ACLMSTR_16TO14_16_, ACLCTRL00, ACLCTRL01_1_0_, ACLCTRL02_1_0_, ACLCTRL03_1_0_, ACLCTRL04_1_0_, ACLCTRL05_5_0_, ACLCTRL06_1_0_, ACLCTRL06_7_2_, ACLCTRL07_1_0_, ACLCTRL07_7_2_, ACLCTRL08_1_0_, ACLCTRL08_7_2_, ACLCMD_15_0_, ACLCMD_23_16_, ACLGPOUT_15_0_, ACLGPIN_15_0_, ACLSTAT0_15_0_, ACLSTAT0_23_16_, LOWPOWER_0_, LOWPOWER_7_1_, LOWPOWER_20_8_, ACL_TAG, ACL_LINK_UPDATE, RDS_I, number_of_settings, special_tag_setting, special_end_setting, special_execute_setting, special_WI2C_setting, special_delay_setting } cx25840_setting; #endif /* __CX25840_SETTINGS_H */ ivtv-utils-1.4.1/utils/cx25840ctl/cmdline.c0000664000076400007640000001646211355717527017012 0ustar andyandy/* File autogenerated by gengetopt version 2.14 generated with the following command: gengetopt -u -i cx25840ctl.ggo The developers of gengetopt consider the fixed text that goes in all gengetopt output files to be in the public domain: we make no copyright claims on it. */ /* If we use autoconf. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include "getopt.h" #include "cmdline.h" static void clear_given (struct gengetopt_args_info *args_info); static void clear_args (struct gengetopt_args_info *args_info); static int cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required, const char *additional_error); static char * gengetopt_strdup (const char *s); static void clear_given (struct gengetopt_args_info *args_info) { args_info->help_given = 0 ; args_info->version_given = 0 ; args_info->list_registers_given = 0 ; args_info->set_registers_given = 0 ; } static void clear_args (struct gengetopt_args_info *args_info) { args_info->list_registers_flag = 0; args_info->set_registers_flag = 0; } void cmdline_parser_print_version (void) { printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION); } void cmdline_parser_print_help (void) { cmdline_parser_print_version (); printf("\n%s\n", "Set and list registers on a CX25840 chip via i2c-dev"); printf("\nUsage: cx25840ctl [OPTIONS]... [FILES]...\n\n"); printf("%s\n"," -h, --help Print help and exit"); printf("%s\n"," -V, --version Print version and exit"); printf("%s\n"," -l, --list-registers dump CX25840 settings to stdout (default=off)"); printf("%s\n"," -s, --set-registers read CX25840 settings from stdin (default=off)"); } void cmdline_parser_init (struct gengetopt_args_info *args_info) { clear_given (args_info); clear_args (args_info); args_info->inputs = NULL; args_info->inputs_num = 0; } static void cmdline_parser_release (struct gengetopt_args_info *args_info) { unsigned int i; for (i = 0; i < args_info->inputs_num; ++i) free (args_info->inputs [i]); if (args_info->inputs_num) free (args_info->inputs); clear_given (args_info); } int cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info) { FILE *outfile; int i = 0; outfile = fopen(filename, "w"); if (!outfile) { fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename); return EXIT_FAILURE; } if (args_info->help_given) { fprintf(outfile, "%s\n", "help"); } if (args_info->version_given) { fprintf(outfile, "%s\n", "version"); } if (args_info->list_registers_given) { fprintf(outfile, "%s\n", "list-registers"); } if (args_info->set_registers_given) { fprintf(outfile, "%s\n", "set-registers"); } fclose (outfile); i = EXIT_SUCCESS; return i; } void cmdline_parser_free (struct gengetopt_args_info *args_info) { cmdline_parser_release (args_info); } /* gengetopt_strdup() */ /* strdup.c replacement of strdup, which is not standard */ char * gengetopt_strdup (const char *s) { char *result = NULL; if (!s) return result; result = (char*)malloc(strlen(s) + 1); if (result == (char*)0) return (char*)0; strcpy(result, s); return result; } int cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info) { return cmdline_parser2 (argc, argv, args_info, 0, 1, 1); } int cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) { int result; result = cmdline_parser_internal (argc, argv, args_info, override, initialize, check_required, NULL); if (result == EXIT_FAILURE) { cmdline_parser_free (args_info); exit (EXIT_FAILURE); } return result; } int cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name) { return EXIT_SUCCESS; } int cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required, const char *additional_error) { int c; /* Character of the parsed option. */ int error = 0; struct gengetopt_args_info local_args_info; if (initialize) cmdline_parser_init (args_info); cmdline_parser_init (&local_args_info); optarg = 0; optind = 1; opterr = 1; optopt = '?'; while (1) { int option_index = 0; char *stop_char; static struct option long_options[] = { { "help", 0, NULL, 'h' }, { "version", 0, NULL, 'V' }, { "list-registers", 0, NULL, 'l' }, { "set-registers", 0, NULL, 's' }, { NULL, 0, NULL, 0 } }; stop_char = 0; c = getopt_long (argc, argv, "hVls", long_options, &option_index); if (c == -1) break; /* Exit from `while (1)' loop. */ switch (c) { case 'h': /* Print help and exit. */ cmdline_parser_print_help (); cmdline_parser_free (&local_args_info); exit (EXIT_SUCCESS); case 'V': /* Print version and exit. */ cmdline_parser_print_version (); cmdline_parser_free (&local_args_info); exit (EXIT_SUCCESS); case 'l': /* dump CX25840 settings to stdout. */ if (local_args_info.list_registers_given) { fprintf (stderr, "%s: `--list-registers' (`-l') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->list_registers_given && ! override) continue; local_args_info.list_registers_given = 1; args_info->list_registers_given = 1; args_info->list_registers_flag = !(args_info->list_registers_flag); break; case 's': /* read CX25840 settings from stdin. */ if (local_args_info.set_registers_given) { fprintf (stderr, "%s: `--set-registers' (`-s') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->set_registers_given && ! override) continue; local_args_info.set_registers_given = 1; args_info->set_registers_given = 1; args_info->set_registers_flag = !(args_info->set_registers_flag); break; case 0: /* Long option with no short option */ case '?': /* Invalid option. */ /* `getopt_long' already printed an error message. */ goto failure; default: /* bug: option not considered. */ fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : "")); abort (); } /* switch */ } /* while */ cmdline_parser_release (&local_args_info); if ( error ) return (EXIT_FAILURE); if (optind < argc) { int i = 0 ; args_info->inputs_num = argc - optind ; args_info->inputs = (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ; while (optind < argc) args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind++]) ; } return 0; failure: cmdline_parser_release (&local_args_info); return (EXIT_FAILURE); } ivtv-utils-1.4.1/utils/cx25840ctl/Makefile0000664000076400007640000000030411355717527016657 0ustar andyandyall: cx25840ctl clean: rm -f *.o cx25840ctl cx25840ctl: cx25840ctl.o cx25840-registers.o cmdline.o cmdline.c: gengetopt -u -i cx25840ctl.ggo cx25840ctl.1: cx25840ctl help2man -N -o $@ ./$^ ivtv-utils-1.4.1/utils/Makefile0000664000076400007640000000232711355717530015140 0ustar andyandyPREFIX = /usr/local BINDIR = $(PREFIX)/bin HDRDIR = /usr/include/linux X86 := $(shell if echo - | $(CC) -E -dM - | egrep -e '__i386__|__x86_64__' >/dev/null; \ then echo y; else echo n; fi) ifeq ($(X86),y) X86_EXES := ivtvplay ivtv-mpegindex #ivtv-encoder endif EXES := v4l2-ctl ivtv-ctl ivtv-radio $(X86_EXES) BIN := $(EXES) ivtv-tune/ivtv-tune cx25840ctl/cx25840ctl HEADERS := linux/ivtv.h linux/ivtvfb.h CFLAGS = -D_GNU_SOURCE -O2 -Wall -g -I. CXXFLAGS = $(CFLAGS) all:: $(EXES) $(MAKE) CFLAGS="$(CFLAGS)" -C ivtv-tune $(MAKE) CFLAGS="$(CFLAGS)" -C cx25840ctl ivtv-ctl: ivtv-ctl.o $(CC) -lm -o $@ $^ v4l2-ctl: v4l2-ctl.o $(CXX) -lm -o $@ $^ v4l2-dbg: v4l2-dbg.o v4l2-driverids.o v4l2-chipids.o $(CXX) -lm -o $@ $^ ivtvplay: ivtvplay.cc $(CXX) $(CXXFLAGS) -lm -lpthread -o $@ $^ encoder.o: encoder.c $(CC) $(CFLAGS) -DVIDEO_PORT=0 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -c $^ ivtv-encoder: enc_mindex.o enc_chann.o encoder.o $(CC) -lpthread -o $@ $^ install: all install -d $(DESTDIR)/$(HDRDIR) install -m 0644 $(HEADERS) $(DESTDIR)/$(HDRDIR) install -d $(DESTDIR)/$(BINDIR) install -m 0755 $(BIN) $(DESTDIR)/$(BINDIR) clean: rm -f *.o $(EXES) $(MAKE) -C ivtv-tune clean $(MAKE) -C cx25840ctl clean ivtv-utils-1.4.1/utils/ivtv-mpegindex.c0000664000076400007640000003216011355717530016610 0ustar andyandy//++MTY use e.g., mpegcat -dV /video/1011_20030808233000_20030809000000.nuv /* # # MPEG2Parser class testing tool # # $Id: mpegindex.c,v 1.2.2.1 2004/04/01 03:46:13 knup Exp $ # # Copyright (C) 2001-2003 Kees Cook # kees@outflux.net, http://outflux.net/ # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # http://www.gnu.org/copyleft/gpl.html # */ /* * buffer management inspired by mplayer */ #define _FILE_OFFSET_BITS 64 #include #include #include #include #include #include #include #include #include #include #include #include #include "mpeg2structs.h" // general stuff int debug = 0; int dvd_names = 0; // file position options loff_t begin_at = 0; loff_t num_bytes = 0; typedef enum { PACK_NONE, PACK_SPECIAL, PACK_PES_SIMPLE, // packet length == data length PACK_PES_COMPLEX, // crazy headers need skipping } packet_type; typedef enum { SUBID_NONE, // no sub id (sid=0) SUBID_DATA, // first PES data byte } subid_type; // FIXME: // - add "valid scope" flags (eg some markers only valid in Video stream) // - add "struct size" field for auto-forwarding past each marker typedef struct { // the byte value match for the packet tags uint8_t code_match_lo; // low end of the range of matches uint8_t code_match_hi; // high end of the range of matches // what kind of PES is it? packet_type packet; // how do we find the stream sub id subid_type subid_method; // misc stuff... sorting types? } packet_tag_info; packet_tag_info packet_tags[] = { {0x00, 0x00, PACK_SPECIAL, SUBID_NONE}, // pic start {0x01, 0xAF, PACK_SPECIAL, SUBID_NONE}, // video slices {0xB0, 0xB1, PACK_SPECIAL, SUBID_NONE}, // reserved {0xB2, 0xB5, PACK_SPECIAL, SUBID_NONE}, // user data, sequences {0xB6, 0xB6, PACK_SPECIAL, SUBID_NONE}, // reserved {0xB7, 0xB9, PACK_SPECIAL, SUBID_NONE}, // sequence, gop, end {0xBA, 0xBA, PACK_SPECIAL, SUBID_NONE}, // pack {0xBB, 0xBB, PACK_PES_SIMPLE, SUBID_NONE}, // system: same len as PES {0xBC, 0xBC, PACK_PES_SIMPLE, SUBID_NONE}, // PES: prog stream map {0xBD, 0xBD, PACK_PES_COMPLEX, SUBID_DATA}, // PES: priv 1 {0xBE, 0xBF, PACK_PES_SIMPLE, SUBID_NONE}, // PES: padding, priv 2 {0xC0, 0xDF, PACK_PES_COMPLEX, SUBID_NONE}, // PES: Audio {0xE0, 0xEF, PACK_PES_COMPLEX, SUBID_NONE}, // PES: Video {0xF0, 0xF2, PACK_PES_SIMPLE, SUBID_NONE}, // PES: ecm, emm, dsmcc {0xF3, 0xF7, PACK_PES_COMPLEX, SUBID_NONE}, // PES: iso 13522/h2221a-d {0xF8, 0xF8, PACK_PES_SIMPLE, SUBID_NONE}, // PES: h2221e {0xF9, 0xF9, PACK_PES_COMPLEX, SUBID_NONE}, // PES: ancillary {0xFA, 0xFE, PACK_PES_SIMPLE, SUBID_NONE}, // PES: reserved {0xFF, 0xFF, PACK_PES_SIMPLE, SUBID_NONE}, // PES: prog stream dir {0, 0, PACK_NONE, SUBID_NONE} // end of list }; #define BUFFER_SIZE (1024*512) FILE *fp = NULL; uint8_t buffer[BUFFER_SIZE]; loff_t offset = 0; size_t buffer_min = 0; size_t buffer_max = 0; loff_t buffer_tell() { return offset - buffer_max + buffer_min; } // can point to a file offset to refill from void buffer_refill() { size_t got; //fprintf(stderr,"filling...\n"); if (buffer_min < buffer_max) { memmove(buffer, buffer + buffer_min, buffer_max - buffer_min); } buffer_max -= buffer_min; buffer_min = 0; got = fread(buffer + buffer_max, sizeof(uint8_t), BUFFER_SIZE - buffer_max, fp); if (got < 0) { perror("fread"); exit(2); } offset += got; buffer_max += got; //fprintf(stderr,"bump %d more\n",got); } void buffer_seek(loff_t location) { // is this location within our current buffer? if (location < offset && location >= buffer_tell()) { buffer_min += location - buffer_tell(); } else { // outside: clear the buffer buffer_min = buffer_max = 0; // clear buffer offset = location; if (fseeko(fp, offset, SEEK_SET) < 0) { fprintf(stderr, "fseeko failed: err = %s\n", strerror(errno)); exit(1); } } //don't do this... way too slow //buffer_refill(); } int buffer_start(char *filename) { if (fp) fclose(fp); fp = NULL; if (!(fp = fopen(filename, "r"))) { perror(filename); return -1; } offset = 0; buffer_min = 0; buffer_max = 0; return 0; } int buffer_get_byte(uint8_t * byte) { if (!byte) return -2; if (buffer_min == buffer_max) buffer_refill(); if (buffer_min == buffer_max) return -1; *byte = buffer[buffer_min++]; return 0; } int buffer_look_ahead(uint8_t * bytes, int count) { int i; if (!bytes) return -2; if (count <= 0) return 0; if (count >= BUFFER_SIZE) return -3; if (buffer_min + count > buffer_max) buffer_refill(); if (buffer_min + count > buffer_max) return -1; for (i = 0; i < count; i++) { *(bytes++) = buffer[buffer_min + i]; //fprintf(stderr,"\tsaw: 0x%02X\n",buffer[buffer_min+i]); } return 0; } uint8_t packet_buffer[65536]; // max size of a double byte uint8_t *packet_start; uint16_t packet_size; loff_t file_offset_of_last_packet = 0; uint32_t framecount = 0; typedef union { struct { uint32_t padding:5, broken:1, closed:1, frame:6, second:6, padding2:1, minute:6, hour:5, drop:1; }; struct { uint32_t data; }; } gop_header_t; struct mpeg_index_entry { unsigned int frame; gop_header_t timestamp; unsigned long long offset; }; FILE *indexfd = NULL; struct mpeg_index_entry last_index_written; int last_was_gop_packet = 0; static inline uint32_t bswap(uint32_t x) { asm("bswap %0": "=r"(x):"0"(x)); return x; } char *timestamp_to_string(char *str, gop_header_t timestamp) { static char buf[256]; char *p = (str) ? str : buf; snprintf(p, sizeof(buf), "%d:%02d:%02d:%d", timestamp.hour, timestamp.minute, timestamp.second, timestamp.frame); return p; } static inline gop_header_t make_timestamp(int hour, int minute, int second, int frame) { gop_header_t gop; gop.hour = hour; gop.minute = minute; gop.second = second; gop.frame = frame; return gop; } loff_t process_packet(uint8_t code) { uint8_t bytes[32]; int i; unsigned int length, header_len; loff_t position = 0; //unsigned long long system_clock_ref_base; // "H"igh, "M"edium, "L"ow bits //unsigned long system_clock_ref_ext; // "E" //unsigned int program_mux_rate; // "R" //unsigned int pack_stuffing_length; // "S" loff_t file_offset = buffer_tell() - 4; // initialize "unknown" packet length header_len = length = 0; last_was_gop_packet = 0; // find the packet type for (i = 0; packet_tags[i].packet != PACK_NONE; i++) { if (code >= packet_tags[i].code_match_lo && code <= packet_tags[i].code_match_hi) { int sid = 0; switch (packet_tags[i].packet) { case PACK_SPECIAL: // actually, nothing special break; case PACK_PES_SIMPLE: case PACK_PES_COMPLEX: if (packet_tags[i].packet == PACK_PES_COMPLEX) { if (buffer_look_ahead(bytes, 5) != 0) return 0; header_len = 5 + bytes[4]; if (dvd_names && packet_tags[i].subid_method == SUBID_DATA && buffer_look_ahead(bytes, header_len + 1) == 0) { sid = bytes[header_len]; } } else { if (buffer_look_ahead(bytes, 2) != 0) return 0; } length = bytes[1] | (bytes[0] << 8); // get position updated for next packet location if ((code & PES_TYPE_MASK_video) == PES_TYPE_video) break; // skip position update position = buffer_tell() + length + 2; break; default: case PACK_NONE: // FIXME: not possible! break; } break; // found a match } } if (code == PES_TYPE_pack_start) { //++MTY file_offset_of_last_packet = file_offset; if (buffer_look_ahead(bytes, 10) == 0) { //| 0 | 1 | 2 | 3 | 4 | 5 | 6 | // 76543210765432107654321076543210765432107654321076543210 // xxHHHxMMMMMMMMMMMMMMMxLLLLLLLLLLLLLLLxEEEEEEEEExRRRRRRRR // 333 222222222211111 111110000000000 000000000 22111111// bit // 210 987654321098765 432109876543210 876543210 10987654// number // - - - - - - - - - - // 2 2 2 1 1 0 - 0 - 1// left // 7 8 0 2 3 5 3 7 1 4// shift // //| 7 | 8 | 9 | // 765432107654321076543210 // RRRRRRRRRRRRRRxxrrrrrSSS // 11110000000000 00000000 // bit // 32109876543210 43210210 // number // - - - - // 0 - - 0 // left // 6 2 3 0 // shift #if 0 int system_clock_ref_base = (((bytes[0] & 0x38) << 27) | ((bytes[0] & 0x03) << 28) | ((bytes[1] & 0xFF) << 20) | ((bytes[2] & 0xF8) << 12) | ((bytes[2] & 0x03) << 13) | ((bytes[3] & 0xFF) << 5) | ((bytes[4] & 0xF8) >> 3)); int system_clock_ref_ext = (((bytes[4] & 0x03) << 7) | ((bytes[5] & 0xFE) >> 1)); int program_mux_rate = (((bytes[6] & 0xFF) << 14) | ((bytes[7] & 0xFF) << 6) | ((bytes[8] & 0xFC) >> 2)); int pack_stuffing_length = (bytes[9] & 0x07); #endif //sprintf(answer, "Pack Start (Mux Rate: %u Stuffing: %u)", // FIXME: too many damn bits // system_clock_ref_base, // system_clock_ref_ext, //program_mux_rate, pack_stuffing_length); //return answer; } else { //return "Pack Start (incomplete flags)"; } } else if (code == PES_TYPE_group_start) { //if (buffer_look_ahead(bytes, 4) == 0) { gop_header_t gop; if (buffer_look_ahead((uint8_t *)&gop, sizeof(gop)) == 0) { gop.data = bswap(gop.data); /* int drop = ((bytes[0] & 0x80) > 0); int hour = ((bytes[0] & 0x7C) >> 2); int min = ((bytes[0] & 0x3) << 4) | ((bytes[1] & 0xF0) >> 4); int sec = ((bytes[1] & 0x7) << 3) | ((bytes[2] & 0xE0) >> 6); int pictures = ((bytes[2] & 0x3F) << 1) | ((bytes[3] & 0x80) >> 7); int closed = ((bytes[3] & 0x40) > 0); int broken = ((bytes[3] & 0x20) > 0); */ /* sprintf(answer, " GOP Start (%02d:%02d:%02d.%02d%s%s%s)", hour, min, sec, pictures, drop ? " drop" : "", closed ? " closed" : " open", broken ? " broken" : ""); */ gop.padding2 = gop.padding = gop.closed = gop.broken = gop.drop = 0; last_index_written.frame = framecount; last_index_written.timestamp = gop; //((unsigned long long)((gop.hour * (60*60)) + (gop.minute*60) + gop.second) << 32LL) + gop.frame; last_index_written.offset = file_offset_of_last_packet; if (indexfd) fwrite(&last_index_written, sizeof(last_index_written), 1, indexfd); last_was_gop_packet = 1; //printf("==> % 15lld: GOP 0x%08x (%02d:%02d:%02d.%02d) on frame %d; %s %s %s\n", file_offset_of_last_packet, (int)(last_index_written.timestamp.data), gop.hour, gop.minute, gop.second, gop.frame, //framecount, (gop.closed) ? "closed" : "", (gop.broken) ? "broken" : "", (gop.drop) ? "drop" : ""); } else { //return " GOP Start (incomplete flags)"; } } else if (code == PES_TYPE_picture_start) { framecount++; } return position; } int main(int argc, char *argv[]) { uint32_t marker; uint8_t byte; int running = 1; if (argc < 3) { fprintf(stderr, "mpegindex: Syntax is mpegindex mpegfile indexfile\n\n"); return -1; } indexfd = fopen(argv[2], "w"); if (!indexfd) { fprintf(stderr, "mpegindex: Error: cannot create index file %s.\n", argv[2]); return -2; } if (buffer_start(argv[1]) < 0) { fprintf(stderr, "mpegindex: Error: cannot open mpeg file %s.\n", argv[1]); return -3; } buffer_seek(begin_at); marker = 0xFFFFFFFF; while (running) { //fprintf(stderr,"%08X\n",marker); if ((marker & 0xFFFFFF00) == 0x100) { loff_t newpos = process_packet(byte); // we skipped to a new location? if (newpos != 0) { //fprintf(stdout,"skipping to %" OFF_T_FORMAT "\n",newpos); marker = 0xFFFFFFFF; buffer_seek(newpos); } } marker <<= 8; if (buffer_get_byte(&byte) < 0) { running = 0; } else marker |= byte; if (num_bytes && buffer_tell() - begin_at > num_bytes) { running = 0; } if (last_was_gop_packet && ((last_index_written.timestamp.second % 30) == 0)) { fprintf(stdout, "\r%s: Processed frame %d at %s (file offset %lld)", argv[1], last_index_written.frame, timestamp_to_string(NULL, last_index_written. timestamp), last_index_written.offset); fflush(stdout); } } fprintf(stdout, "\r%s: Processed %d frames covering time %s (file size %lld)\n\n", argv[1], last_index_written.frame, timestamp_to_string(NULL, last_index_written. timestamp), last_index_written.offset); fclose(indexfd); return 0; } ivtv-utils-1.4.1/Makefile0000664000076400007640000000011111355717530013765 0ustar andyandyall clean install: make -C utils $@ make -C test $@ distclean: clean