Lines Matching +full:south +full:- +full:field

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Derived from cx25840-core.c
11 #include "cx18-driver.h"
12 #include "cx18-io.h"
13 #include "cx18-cards.h"
106 /* xtal * 0xe.2913d68/0x16 = 48000 * 384: 406 MHz pre post-div*/ in cx18_av_init()
127 /* enable sleep mode - register appears to be read only... */ in cx18_av_initialize()
167 * Disable Video Auto-config of the Analog Front End and Video PLL. in cx18_av_initialize()
171 * 0x102 (CXADEC_CHIP_CTRL), 0x104-0x106 (CXADEC_AFE_CTRL), in cx18_av_initialize()
172 * 0x108-0x109 (CXADEC_PLL_CTRL1), and 0x10c-0x10f (CXADEC_VID_PLL_FRAC) in cx18_av_initialize()
173 * ourselves, than to run around cleaning up after the auto-config. in cx18_av_initialize()
186 /* set video to auto-detect */ in cx18_av_initialize()
187 /* Clear bits 11-12 to enable slow locking mode. Set autodetect mode */ in cx18_av_initialize()
200 * VIP-1.1, 10 bit mode, enable Raw, disable sliced, in cx18_av_initialize()
201 * don't clamp raw samples when codes are in use, 1 byte user D-words, in cx18_av_initialize()
209 /* EncSetSignalStd(dwDevNum, pEnc->dwSigStd); */ in cx18_av_initialize()
210 /* EncSetVideoInput(dwDevNum, pEnc->VidIndSelection); */ in cx18_av_initialize()
215 * bypass_ch[1-3] use filter in cx18_av_initialize()
216 * droop_comp_ch[1-3] disable in cx18_av_initialize()
217 * clamp_en_ch[1-3] disable in cx18_av_initialize()
221 * clamp_sel_ch[2-3] midcode in cx18_av_initialize()
224 * vga_sel_ch[1-2] video decoder in cx18_av_initialize()
225 * half_bw_ch[1-3] disable in cx18_av_initialize()
226 * +12db_ch[1-3] disable in cx18_av_initialize()
239 * -ERANGE errors when initializing the volume control in cx18_av_initialize()
242 /* Bottom out at -96 dB, v4l2 vol range 0x2e00-0x2fff */ in cx18_av_initialize()
246 /* Top out at + 8 dB, v4l2 vol range 0xfe00-0xffff */ in cx18_av_initialize()
250 default_volume = (((228 - default_volume) >> 1) + 23) << 9; in cx18_av_initialize()
251 state->volume->cur.val = state->volume->default_value = default_volume; in cx18_av_initialize()
252 v4l2_ctrl_handler_setup(&state->hdl); in cx18_av_initialize()
265 if (!state->is_initialized) { in cx18_av_load_fw()
267 state->is_initialized = 1; in cx18_av_load_fw()
275 struct cx18_av_state *state = &cx->av_state; in cx18_av_std_setup()
276 struct v4l2_subdev *sd = &state->sd; in cx18_av_std_setup()
277 v4l2_std_id std = state->std; in cx18_av_std_setup()
297 * Note: At the end of a field, there are 3 sets of half line duration in cx18_av_std_setup()
300 * 5 (625) or 6 (525) half-lines to blank for the vertical retrace in cx18_av_std_setup()
302 * 5 (625) or 6 (525) half-lines of equalization pulses in cx18_av_std_setup()
308 * 10 = vblank656 - vblank = vsync pulses + equalization pulses in cx18_av_std_setup()
310 * vblank656: half lines after line 625/mid-313 of blanked video in cx18_av_std_setup()
317 * vsync pulse (start of line 1 or mid-313) in cx18_av_std_setup()
322 * from lines 6-23 and lines 318-335 (but the slicer can only in cx18_av_std_setup()
327 * extract line 23 & 335 (WSS). We'll lose 1 line in each field in cx18_av_std_setup()
334 * without them (at least when a PVR-350 is the PAL source). in cx18_av_std_setup()
336 vblank656 = 48; /* lines 1 - 24 & 313 - 336 */ in cx18_av_std_setup()
337 vblank = 38; /* lines 6 - 24 & 318 - 336 */ in cx18_av_std_setup()
338 vactive = 579; /* lines 24 - 313 & 337 - 626 */ in cx18_av_std_setup()
342 * 864 pixels = 720 active + 144 blanking. ITU-R BT.601 in cx18_av_std_setup()
380 * 12 = vblank656 - vblank = vsync pulses + equalization pulses in cx18_av_std_setup()
382 * prevsync: 6 half-lines before the vsync pulses in cx18_av_std_setup()
383 * vblank656: half lines, after line 3/mid-266, of blanked video in cx18_av_std_setup()
389 * vsync pulse (start of line 4 or mid-266) in cx18_av_std_setup()
394 * from lines 10-21 and lines 273-284. in cx18_av_std_setup()
396 vblank656 = 38; /* lines 4 - 22 & 266 - 284 */ in cx18_av_std_setup()
397 vblank = 26; /* lines 10 - 22 & 272 - 284 */ in cx18_av_std_setup()
398 vactive = 481; /* lines 23 - 263 & 285 - 525 */ in cx18_av_std_setup()
426 /* The 97 needs to be verified against PAL-M timings */ in cx18_av_std_setup()
465 "Chroma sub-carrier initial freq = %d.%06d MHz\n", in cx18_av_std_setup()
507 state->slicer_line_delay = 1; in cx18_av_std_setup()
508 state->slicer_line_offset = (6 + state->slicer_line_delay - 2); in cx18_av_std_setup()
510 state->slicer_line_delay = 0; in cx18_av_std_setup()
511 state->slicer_line_offset = (10 + state->slicer_line_delay - 2); in cx18_av_std_setup()
513 cx18_av_write(cx, 0x47f, state->slicer_line_delay); in cx18_av_std_setup()
518 struct cx18_av_state *state = &cx->av_state; in input_change()
519 v4l2_std_id std = state->std; in input_change()
533 /* South Korea uses A2 audio standard */ in input_change()
572 struct cx18_av_state *state = &cx->av_state; in set_input()
573 struct v4l2_subdev *sd = &state->sd; in set_input()
590 afe_mux_cfg = 0xf0 + (vid_input - CX18_AV_COMPOSITE1); in set_input()
607 return -EINVAL; in set_input()
609 afe_mux_cfg = (luma - CX18_AV_COMPONENT_LUMA1) >> 12; in set_input()
611 afe_mux_cfg |= (r_chroma - CX18_AV_COMPONENT_R_CHROMA4) >> 12; in set_input()
613 afe_mux_cfg |= (b_chroma - CX18_AV_COMPONENT_B_CHROMA7) >> 14; in set_input()
627 return -EINVAL; in set_input()
629 afe_mux_cfg = 0xf0 + ((luma - CX18_AV_SVIDEO_LUMA1) >> 4); in set_input()
633 afe_mux_cfg |= (chroma - CX18_AV_SVIDEO_CHROMA7) >> 2; in set_input()
637 afe_mux_cfg |= (chroma - CX18_AV_SVIDEO_CHROMA4) >> 4; in set_input()
672 return -EINVAL; in set_input()
677 /* Set INPUT_MODE to Composite, S-Video, or Component */ in set_input()
699 afe_cfg |= 0x00000030; /* half_bw_ch[2-3] since in dual mode */ in set_input()
735 state->vid_input = vid_input; in set_input()
736 state->aud_input = aud_input; in set_input()
747 return set_input(cx, input, state->aud_input); in cx18_av_s_video_routing()
755 return set_input(cx, state->vid_input, input); in cx18_av_s_audio_routing()
766 if (state->radio) in cx18_av_g_tuner()
770 vt->signal = vpres ? 0xffff : 0x0; in cx18_av_g_tuner()
772 vt->capability |= in cx18_av_g_tuner()
790 vt->rxsubchans = val; in cx18_av_g_tuner()
791 vt->audmode = state->audmode; in cx18_av_g_tuner()
801 if (state->radio) in cx18_av_s_tuner()
807 switch (vt->audmode) { in cx18_av_s_tuner()
809 /* mono -> mono in cx18_av_s_tuner()
810 stereo -> mono in cx18_av_s_tuner()
811 bilingual -> lang1 */ in cx18_av_s_tuner()
815 /* mono -> mono in cx18_av_s_tuner()
816 stereo -> stereo in cx18_av_s_tuner()
817 bilingual -> lang1 */ in cx18_av_s_tuner()
821 /* mono -> mono in cx18_av_s_tuner()
822 stereo -> stereo in cx18_av_s_tuner()
823 bilingual -> lang1/lang2 */ in cx18_av_s_tuner()
827 /* mono -> mono in cx18_av_s_tuner()
828 stereo -> stereo in cx18_av_s_tuner()
829 bilingual -> lang2 */ in cx18_av_s_tuner()
833 return -EINVAL; in cx18_av_s_tuner()
836 state->audmode = vt->audmode; in cx18_av_s_tuner()
848 if (state->radio == 0 && state->std == norm) in cx18_av_s_std()
851 state->radio = 0; in cx18_av_s_std()
852 state->std = norm; in cx18_av_s_std()
855 if (state->std == V4L2_STD_NTSC_M_JP) { in cx18_av_s_std()
857 } else if (state->std == V4L2_STD_NTSC_443) { in cx18_av_s_std()
859 } else if (state->std == V4L2_STD_PAL_M) { in cx18_av_s_std()
862 } else if (state->std == V4L2_STD_PAL_N) { in cx18_av_s_std()
864 } else if (state->std == V4L2_STD_PAL_Nc) { in cx18_av_s_std()
866 } else if (state->std == V4L2_STD_PAL_60) { in cx18_av_s_std()
870 if (state->std & V4L2_STD_NTSC) in cx18_av_s_std()
872 else if (state->std & V4L2_STD_PAL) in cx18_av_s_std()
874 else if (state->std & V4L2_STD_SECAM) in cx18_av_s_std()
884 /* Set format to NTSC-M */ in cx18_av_s_std()
899 state->radio = 1; in cx18_av_s_radio()
908 switch (ctrl->id) { in cx18_av_s_ctrl()
910 cx18_av_write(cx, 0x414, ctrl->val - 128); in cx18_av_s_ctrl()
914 cx18_av_write(cx, 0x415, ctrl->val << 1); in cx18_av_s_ctrl()
918 cx18_av_write(cx, 0x420, ctrl->val << 1); in cx18_av_s_ctrl()
919 cx18_av_write(cx, 0x421, ctrl->val << 1); in cx18_av_s_ctrl()
923 cx18_av_write(cx, 0x422, ctrl->val); in cx18_av_s_ctrl()
927 return -EINVAL; in cx18_av_s_ctrl()
936 struct v4l2_mbus_framefmt *fmt = &format->format; in cx18_av_set_fmt()
940 int is_50Hz = !(state->std & V4L2_STD_525_60); in cx18_av_set_fmt()
942 if (format->pad || fmt->code != MEDIA_BUS_FMT_FIXED) in cx18_av_set_fmt()
943 return -EINVAL; in cx18_av_set_fmt()
945 fmt->field = V4L2_FIELD_INTERLACED; in cx18_av_set_fmt()
946 fmt->colorspace = V4L2_COLORSPACE_SMPTE170M; in cx18_av_set_fmt()
961 Vlines = fmt->height + (is_50Hz ? 3 : 1); in cx18_av_set_fmt()
970 if ((fmt->width * 16 < Hsrc) || (Hsrc < fmt->width) || in cx18_av_set_fmt()
973 fmt->width, fmt->height); in cx18_av_set_fmt()
974 return -ERANGE; in cx18_av_set_fmt()
977 if (format->which == V4L2_SUBDEV_FORMAT_TRY) in cx18_av_set_fmt()
980 HSC = (Hsrc * (1 << 20)) / fmt->width - (1 << 20); in cx18_av_set_fmt()
981 VSC = (1 << 16) - (Vsrc * (1 << 9) / Vlines - (1 << 9)); in cx18_av_set_fmt()
984 if (fmt->width >= 385) in cx18_av_set_fmt()
986 else if (fmt->width > 192) in cx18_av_set_fmt()
988 else if (fmt->width > 96) in cx18_av_set_fmt()
994 "decoder set size %dx%d -> scale %ux%u\n", in cx18_av_set_fmt()
995 fmt->width, fmt->height, HSC, VSC); in cx18_av_set_fmt()
1028 "NTSC-M", "NTSC-J", "NTSC-4.43", in log_video_status()
1029 "PAL-BDGHI", "PAL-M", "PAL-N", "PAL-Nc", "PAL-60", in log_video_status()
1035 struct cx18_av_state *state = &cx->av_state; in log_video_status()
1036 struct v4l2_subdev *sd = &state->sd; in log_video_status()
1040 int vid_input = state->vid_input; in log_video_status()
1054 vid_input - CX18_AV_COMPOSITE1 + 1); in log_video_status()
1056 CX18_INFO_DEV(sd, "Specified video input: S-Video (Luma In%d, Chroma In%d)\n", in log_video_status()
1062 state->audclk_freq); in log_video_status()
1067 struct cx18_av_state *state = &cx->av_state; in log_audio_status()
1068 struct v4l2_subdev *sd = &state->sd; in log_audio_status()
1076 int aud_input = state->aud_input; in log_audio_status()
1096 case 0x02: p = "A2-M"; break; in log_audio_status()
1097 case 0x03: p = "A2-BG"; break; in log_audio_status()
1098 case 0x04: p = "A2-DK1"; break; in log_audio_status()
1099 case 0x05: p = "A2-DK2"; break; in log_audio_status()
1100 case 0x06: p = "A2-DK3"; break; in log_audio_status()
1102 case 0x08: p = "AM-L"; break; in log_audio_status()
1103 case 0x09: p = "NICAM-BG"; break; in log_audio_status()
1104 case 0x0a: p = "NICAM-DK"; break; in log_audio_status()
1105 case 0x0b: p = "NICAM-I"; break; in log_audio_status()
1106 case 0x0c: p = "NICAM-L"; break; in log_audio_status()
1107 case 0x0d: p = "BTSC/EIAJ/A2-M Mono (4.5 MHz FMMono)"; break; in log_audio_status()
1126 case 0x03: p = "A2-M"; break; in log_audio_status()
1127 case 0x04: p = "A2-BG"; break; in log_audio_status()
1128 case 0x05: p = "A2-DK1"; break; in log_audio_status()
1129 case 0x06: p = "A2-DK2"; break; in log_audio_status()
1130 case 0x07: p = "A2-DK3"; break; in log_audio_status()
1132 case 0x09: p = "AM-L"; break; in log_audio_status()
1133 case 0x0a: p = "NICAM-BG"; break; in log_audio_status()
1134 case 0x0b: p = "NICAM-DK"; break; in log_audio_status()
1135 case 0x0c: p = "NICAM-I"; break; in log_audio_status()
1136 case 0x0d: p = "NICAM-L"; break; in log_audio_status()
1148 case 0x03: p = "MONO4 (NICAM ANALOG-Language C/Analog Fallback)"; break; in log_audio_status()
1166 case 0x08: p = "A2-M"; break; in log_audio_status()
1169 case 0x0b: p = "S-Video"; break; in log_audio_status()
1206 case 3: p = "A2-M"; break; in log_audio_status()
1228 if ((reg->reg & 0x3) != 0) in cx18_av_g_register()
1229 return -EINVAL; in cx18_av_g_register()
1230 reg->size = 4; in cx18_av_g_register()
1231 reg->val = cx18_av_read4(cx, reg->reg & 0x00000ffc); in cx18_av_g_register()
1240 if ((reg->reg & 0x3) != 0) in cx18_av_s_register()
1241 return -EINVAL; in cx18_av_s_register()
1242 cx18_av_write4(cx, reg->reg & 0x00000ffc, reg->val); in cx18_av_s_register()
1301 struct cx18_av_state *state = &cx->av_state; in cx18_av_probe()
1305 state->rev = cx18_av_read4(cx, CXADEC_CHIP_CTRL) & 0xffff; in cx18_av_probe()
1307 state->vid_input = CX18_AV_COMPOSITE7; in cx18_av_probe()
1308 state->aud_input = CX18_AV_AUDIO8; in cx18_av_probe()
1309 state->audclk_freq = 48000; in cx18_av_probe()
1310 state->audmode = V4L2_TUNER_MODE_LANG1; in cx18_av_probe()
1311 state->slicer_line_delay = 0; in cx18_av_probe()
1312 state->slicer_line_offset = (10 + state->slicer_line_delay - 2); in cx18_av_probe()
1314 sd = &state->sd; in cx18_av_probe()
1317 snprintf(sd->name, sizeof(sd->name), in cx18_av_probe()
1318 "%s %03x", cx->v4l2_dev.name, (state->rev >> 4)); in cx18_av_probe()
1319 sd->grp_id = CX18_HW_418_AV; in cx18_av_probe()
1320 v4l2_ctrl_handler_init(&state->hdl, 9); in cx18_av_probe()
1321 v4l2_ctrl_new_std(&state->hdl, &cx18_av_ctrl_ops, in cx18_av_probe()
1323 v4l2_ctrl_new_std(&state->hdl, &cx18_av_ctrl_ops, in cx18_av_probe()
1325 v4l2_ctrl_new_std(&state->hdl, &cx18_av_ctrl_ops, in cx18_av_probe()
1327 v4l2_ctrl_new_std(&state->hdl, &cx18_av_ctrl_ops, in cx18_av_probe()
1328 V4L2_CID_HUE, -128, 127, 1, 0); in cx18_av_probe()
1330 state->volume = v4l2_ctrl_new_std(&state->hdl, in cx18_av_probe()
1333 v4l2_ctrl_new_std(&state->hdl, in cx18_av_probe()
1336 v4l2_ctrl_new_std(&state->hdl, &cx18_av_audio_ctrl_ops, in cx18_av_probe()
1339 v4l2_ctrl_new_std(&state->hdl, &cx18_av_audio_ctrl_ops, in cx18_av_probe()
1342 v4l2_ctrl_new_std(&state->hdl, &cx18_av_audio_ctrl_ops, in cx18_av_probe()
1345 sd->ctrl_handler = &state->hdl; in cx18_av_probe()
1346 if (state->hdl.error) { in cx18_av_probe()
1347 int err = state->hdl.error; in cx18_av_probe()
1349 v4l2_ctrl_handler_free(&state->hdl); in cx18_av_probe()
1352 err = v4l2_device_register_subdev(&cx->v4l2_dev, sd); in cx18_av_probe()
1354 v4l2_ctrl_handler_free(&state->hdl); in cx18_av_probe()