#include #include #include #include #include #include #include #include "saa713x_ioctl.h" #define DEFAULT_SAA_DEV "/dev/saa0" #define PAL_LINE_COUNT 288 #define PAL_LINE_OFFSET 19 #define NTSC_LINE_COUNT 240 #define NTSC_LINE_OFFSET 16 static const char *opts = "s:o:i:b:f:g:w:x:A:a:C:c:d:l:L:m:M:B:T:S:H:D:"; static char *devname = 0; static const char *usage = "-s : Video Standard, standard is:\n" " p - PAL (default)\n" " n - NTSC\n" "-o : Line Start Offset Adjustment, N is:\n" " -11 < N < +11 (default 0)\n" "-i : Video Input Source, input is:\n" " 1 - CVBS 1\n" " 2 - CVBS 2 (default)\n" " 3 - CVBS 3\n" " 4 - CVBS 4\n" " 5 - CVBS 5\n" " a - S-Video 1 (Auto gain)\n" " b - S-Video 2 (Auto gain)\n" " A - S-Video 1 (No auto gain)\n" " B - S-Video 2 (No auto gain)\n" "-b <0|1> : Bypass Comb Filters:\n" " 0 - No Bypass (default)\n" " 1 - Bypass\n" "-f <0|1> : YComb Filter:\n" " 0 - Disable\n" " 1 - Enable (default)\n" "-g <0|1> : CComb Filter:\n" " 0 - Disable\n" " 1 - Enable (default)\n" "-w <0|1> : White Peak (requires auto luma gain):\n" " 0 - White peak on (default)\n" " 1 - White peak off\n" "-x <0|1> : Color Peak (requires auto chroma gain):\n" " 0 - Color peak on (default)\n" " 1 - Color peak off\n" "-A <0|1> : Auto Luma Gain Control:\n" " 0 - Auto gain (default)\n" " 1 - Fixed gain\n" "-a : Luma Fixed Gain Amount (default 0)\n" "-C <0|1> : Auto Chroma Gain Control:\n" " 0 - Auto gain (default)\n" " 1 - Fixed gain\n" "-c : Chroma Fixed Gain Amount (default 0)\n" "-d <0|1> : Disable Chrominance Vertical Filter:\n" " 0 - Filter enabled (default)\n" " 1 - Filter disabled\n" "-l <0|1> : Luma Bandwith Ratio\n" " 0 - Narrow Chroma, Wide Luma\n" " 1 - Wide Chroma, Narrow Luma (default)\n" "-L : Luma Bandwidth Adjustment, N is:\n" " 0 <= N <= 15 (default 8)\n" "-m <0|1> : Chroma Bandwith Ratio\n" " 0 - Small color difference bandwidth\n" " 1 - Wide color difference bandwidth (default)\n" "-M : Chroma Bandwidth Adjustment, N is:\n" " 0 <= N <= 7 (default 7)\n" "-B : Brightness, 0 - 255\n" " 0 <= N <= 255 (default 128)\n" "-T : Contrast, 0 - 255\n" " 0 <= N <= 255 (default 68)\n" "-S : Saturation, 0 - 255\n" " 0 <= N <= 255 (default 64)\n" "-H : Hue, 0 - 255\n" " 0 <= N <= 255 (default 0)\n" "-D : SAA Device Path (default: /dev/saa0)\n"; static struct saa_video_std video_std = { .std_flag_dfid = 0, .std_flag_no_dved = 0, .std_flag_dhed = 0, .std_first_linenum = 0, .std_video_xinstart = 0, .std_video_xinstop = 719, .std_video_yinstart = 19, .std_video_yinstop = 19 + 287, .std_vbi_xinstart = 0, .std_vbi_xinstop = 0, .std_vbi_yinstart = 0, .std_vbi_yinstop = 0, .std_brightness = 0x80, .std_contrast = 0x44, .std_saturation = 0x40, .std_vbi_raw_src = VBIRAWSRC_YUV }; static struct saa_video_opt video_opt = { .svo_flag_wpoff = 0, .svo_fuse = FUSE_GAON_AAOFF, .svo_input_mode = MODE_CVBS_2, .svo_flag_dtv = 0, .svo_flag_copyprotsrc = 0, .svo_flag_cpoff = 0, .svo_flag_holdg = 0, .svo_flag_fixgain = 0, .svo_adc1_gain = 0x0, .svo_adc2_gain = 0x0, .svo_feild_rate = FRATE_AUTO, .svo_htc_mode = HTCMODE_FAST, .svo_flag_nonpll_mode = 0, .svo_vno_mode = VNOMODE_NORM, .svo_flag_byps = 0, .svo_flag_ycomb = 1, .svo_flag_lubw = 1, .svo_lufi = 8, .svo_brightness = 0x80, .svo_contrast = 0x44, .svo_saturation = 0x40, .svo_hue = 0x00, .svo_flag_no_acgc = 0, .svo_chroma_gain = 0x0, .svo_flag_cdto = 0, .svo_cstd = CSTD_PAL, .svo_flag_dcvf = 0, .svo_flag_fctc = 0, .svo_flag_ccomb = 1, .svo_offv = 0, .svo_offu = 0, .svo_flag_chbw = 1, .svo_lcbw = 7, .svo_ydel = 0, .svo_hdel = 0, .svo_flag_forcecolor = 0, .svo_apck = 1, .svo_aosl = 0, .svo_flag_uptcv = 1, .svo_flag_cm99 = 0, .svo_laty = 3, .svo_adetect_std = ADETECT_DISABLE, }; int main(int argc, char **argv) { int fd, ch, i; while ( (ch = getopt(argc, argv, opts)) != -1) { switch (ch) { case 's': switch(optarg[0]) { case 'P': case 'p': video_std.std_video_yinstart = PAL_LINE_OFFSET; video_std.std_video_yinstop = video_std.std_video_yinstart + PAL_LINE_COUNT - 1; video_opt.svo_cstd = CSTD_PAL; break; case 'N': case 'n': video_std.std_video_yinstart = NTSC_LINE_OFFSET; video_std.std_video_yinstop = video_std.std_video_yinstart + NTSC_LINE_COUNT - 1; video_opt.svo_cstd = CSTD_NTSC; break; default: errx(1, "Invalid standard %s\n\n%s", optarg, usage); } break; case 'o': i = atoi(optarg); if (i < -11 || i > 11) errx(1, "Invalid Line start offset adjustment:" " %d\n\n%s", i, usage); video_std.std_video_yinstart += i; video_std.std_video_yinstop += i; break; case 'i': switch(optarg[0]) { case '1': video_opt.svo_input_mode = MODE_CVBS_1; break; case '2': video_opt.svo_input_mode = MODE_CVBS_2; break; case '3': video_opt.svo_input_mode = MODE_CVBS_3; break; case '4': video_opt.svo_input_mode = MODE_CVBS_4; break; case '5': video_opt.svo_input_mode = MODE_CVBS_5; break; case 'a': video_opt.svo_input_mode = MODE_SVIDEOAGC_1; break; case 'b': video_opt.svo_input_mode = MODE_SVIDEOAGC_2; break; case 'A': video_opt.svo_input_mode = MODE_SVIDEOFIXGC_1; break; case 'B': video_opt.svo_input_mode = MODE_SVIDEOFIXGC_2; break; default: errx(1, "Invalid Input Source: %s\n\n%s", optarg, usage); } break; case 'b': if (optarg[0] != '0' && optarg[0] != '1') errx(1, "Invalid option: %s\n\n%s", optarg, usage); video_opt.svo_flag_byps = optarg[0] - '0'; break; case 'f': if (optarg[0] != '0' && optarg[0] != '1') errx(1, "Invalid option: %s\n\n%s", optarg, usage); video_opt.svo_flag_ycomb = optarg[0] - '0'; break; case 'g': if (optarg[0] != '0' && optarg[0] != '1') errx(1, "Invalid option: %s\n\n%s", optarg, usage); video_opt.svo_flag_ccomb = optarg[0] - '0'; break; case 'w': if (optarg[0] != '0' && optarg[0] != '1') errx(1, "Invalid option: %s\n\n%s", optarg, usage); video_opt.svo_flag_wpoff = optarg[0] - '0'; break; case 'x': if (optarg[0] != '0' && optarg[0] != '1') errx(1, "Invalid option: %s\n\n%s", optarg, usage); video_opt.svo_flag_cpoff = optarg[0] - '0'; break; case 'A': if (optarg[0] != '0' && optarg[0] != '1') errx(1, "Invalid option: %s\n\n%s", optarg, usage); video_opt.svo_flag_fixgain = optarg[0] - '0'; break; case 'a': i = atoi(optarg); i &= 0xff; video_opt.svo_adc1_gain = i; video_opt.svo_adc2_gain = i; break; case 'C': if (optarg[0] != '0' && optarg[0] != '1') errx(1, "Invalid option: %s\n\n%s", optarg, usage); video_opt.svo_flag_no_acgc = optarg[0] - '0'; break; case 'c': i = atoi(optarg); i &= 0xff; video_opt.svo_chroma_gain = i; break; case 'd': if (optarg[0] != '0' && optarg[0] != '1') errx(1, "Invalid option: %s\n\n%s", optarg, usage); video_opt.svo_flag_dcvf = optarg[0] - '0'; break; case 'l': if (optarg[0] != '0' && optarg[0] != '1') errx(1, "Invalid option: %s\n\n%s", optarg, usage); video_opt.svo_flag_lubw = optarg[0] - '0'; break; case 'L': i = atoi(optarg); if (i < 0 || i > 15) errx(1, "Invalid Luma adjustment: %d\n\n%s", i, usage); video_opt.svo_lufi = i; break; case 'm': if (optarg[0] != '0' && optarg[0] != '1') errx(1, "Invalid option: %s\n\n%s", optarg, usage); video_opt.svo_flag_chbw = optarg[0] - '0'; break; case 'M': i = atoi(optarg); if (i < 0 || i > 7) errx(1, "Invalid Chroma adjustment: %d\n\n%s", i, usage); video_opt.svo_lcbw = i; break; case 'B': i = atoi(optarg); if (i < 0 || i > 255) errx(1, "Invalid Brightness: %d\n\n%s", i, usage); video_opt.svo_brightness = i; break; case 'T': i = atoi(optarg); if (i < 0 || i > 255) errx(1, "Invalid Contrast: %d\n\n%s", i, usage); video_opt.svo_contrast = i; break; case 'S': i = atoi(optarg); if (i < 0 || i > 255) errx(1, "Invalid Saturation: %d\n\n%s", i, usage); video_opt.svo_saturation = i; break; case 'H': i = atoi(optarg); if (i < 0 || i > 255) errx(1, "Invalid Hue: %d\n\n%s", i, usage); video_opt.svo_hue = i; break; case 'D': devname = strdup(optarg); break; default: errx(1, "\n%s", usage); } } if (devname == 0) devname = DEFAULT_SAA_DEV; if ( (fd = open(devname, O_RDWR)) == -1) err(errno, "error opening video device: %s", devname); if (ioctl(fd, SETVIDEOSTD, &video_std) == -1) err(errno, "ioctl, SETVIDEOOPT failed"); if (ioctl(fd, SETVIDEOOPT, &video_opt) == -1) err(errno, "ioctl, SETVIDEOOPT failed"); return 0; }