61 static int valid_service_line(
int field,
int line,
int is_pal)
63 return (is_pal && line >= 6 &&
64 ((field == 0 && line <= 23) || (field == 1 && line <= 22))) ||
65 (!is_pal && line >= 10 && line < 22);
75 static u16 select_service_from_set(
int field,
int line,
u16 set,
int is_pal)
80 set =
set & valid_set;
81 if (
set == 0 || !valid_service_line(field, line, is_pal))
94 for (i = 0; i < 32; i++) {
111 for (f = 0; f < 2; f++) {
112 for (l = 0; l < 24; l++)
113 fmt->
service_lines[f][l] = select_service_from_set(f, l,
set, is_pal);
126 for (f = 0; f < 2; f++) {
127 for (l = 0; l < 24; l++) {
141 for (f = 0; f < 2; f++) {
142 for (l = 0; l < 24; l++)
148 static int cx18_g_fmt_vid_cap(
struct file *
file,
void *fh,
152 struct cx18 *cx =
id->cx;
173 static int cx18_g_fmt_vbi_cap(
struct file *file,
void *fh,
176 struct cx18 *cx = fh2id(fh)->cx;
183 vbifmt->
start[0] = cx->
vbi.start[0];
184 vbifmt->
start[1] = cx->
vbi.start[1];
192 static int cx18_g_fmt_sliced_vbi_cap(
struct file *file,
void *fh,
195 struct cx18 *cx = fh2id(fh)->cx;
217 static int cx18_try_fmt_vid_cap(
struct file *file,
void *fh,
221 struct cx18 *cx =
id->cx;
241 static int cx18_try_fmt_vbi_cap(
struct file *file,
void *fh,
244 return cx18_g_fmt_vbi_cap(file, fh, fmt);
247 static int cx18_try_fmt_sliced_vbi_cap(
struct file *file,
void *fh,
250 struct cx18 *cx = fh2id(fh)->cx;
261 if (check_service_set(vbifmt, cx->
is_50hz))
266 static int cx18_s_fmt_vid_cap(
struct file *file,
void *fh,
270 struct cx18 *cx =
id->cx;
271 struct v4l2_mbus_framefmt mbus_fmt;
276 ret = cx18_try_fmt_vid_cap(file, fh, fmt);
282 if (cx->
cxhdl.width == w && cx->
cxhdl.height == h &&
297 mbus_fmt.width = cx->
cxhdl.width =
w;
298 mbus_fmt.height = cx->
cxhdl.height =
h;
301 return cx18_g_fmt_vid_cap(file, fh, fmt);
304 static int cx18_s_fmt_vbi_cap(
struct file *file,
void *fh,
308 struct cx18 *cx =
id->cx;
328 cx->
vbi.sliced_in->service_set = 0;
331 return cx18_g_fmt_vbi_cap(file, fh, fmt);
334 static int cx18_s_fmt_sliced_vbi_cap(
struct file *file,
void *fh,
338 struct cx18 *cx =
id->cx;
342 cx18_try_fmt_sliced_vbi_cap(file, fh, fmt);
361 memcpy(cx->
vbi.sliced_in, vbifmt,
sizeof(*cx->
vbi.sliced_in));
365 static int cx18_g_chip_ident(
struct file *file,
void *fh,
368 struct cx18 *cx = fh2id(fh)->cx;
373 switch (chip->
match.type) {
375 switch (chip->
match.addr) {
378 chip->
revision = cx18_read_reg(cx, 0xC72028);
387 core, g_chip_ident, chip);
417 #ifdef CONFIG_VIDEO_ADV_DEBUG
418 static int cx18_cxc(
struct cx18 *cx,
unsigned int cmd,
void *
arg)
429 cx18_write_enc(cx, regs->
val, regs->
reg);
431 regs->
val = cx18_read_enc(cx, regs->
reg);
435 static int cx18_g_register(
struct file *file,
void *fh,
438 struct cx18 *cx = fh2id(fh)->cx;
447 static int cx18_s_register(
struct file *file,
void *fh,
450 struct cx18 *cx = fh2id(fh)->cx;
460 static int cx18_querycap(
struct file *file,
void *fh,
464 struct cx18 *cx =
id->cx;
469 "PCI:%s", pci_name(cx->
pci_dev));
476 static int cx18_enumaudio(
struct file *file,
void *fh,
struct v4l2_audio *
vin)
478 struct cx18 *cx = fh2id(fh)->cx;
483 static int cx18_g_audio(
struct file *file,
void *fh,
struct v4l2_audio *
vin)
485 struct cx18 *cx = fh2id(fh)->cx;
491 static int cx18_s_audio(
struct file *file,
void *fh,
const struct v4l2_audio *vout)
493 struct cx18 *cx = fh2id(fh)->cx;
502 static int cx18_enum_input(
struct file *file,
void *fh,
struct v4l2_input *
vin)
504 struct cx18 *cx = fh2id(fh)->cx;
510 static int cx18_cropcap(
struct file *file,
void *fh,
513 struct cx18 *cx = fh2id(fh)->cx;
518 cropcap->
bounds.width = 720;
526 static int cx18_s_crop(
struct file *file,
void *fh,
const struct v4l2_crop *crop)
529 struct cx18 *cx =
id->cx;
537 static int cx18_g_crop(
struct file *file,
void *fh,
struct v4l2_crop *crop)
539 struct cx18 *cx = fh2id(fh)->cx;
547 static int cx18_enum_fmt_vid_cap(
struct file *file,
void *fh,
564 *fmt = formats[fmt->
index];
568 static int cx18_g_input(
struct file *file,
void *fh,
unsigned int *i)
570 struct cx18 *cx = fh2id(fh)->cx;
579 struct cx18 *cx =
id->cx;
605 static int cx18_g_frequency(
struct file *file,
void *fh,
608 struct cx18 *cx = fh2id(fh)->cx;
620 struct cx18 *cx =
id->cx;
632 static int cx18_g_std(
struct file *file,
void *fh,
v4l2_std_id *
std)
634 struct cx18 *cx = fh2id(fh)->cx;
643 struct cx18 *cx =
id->cx;
663 cx->
cxhdl.width = 720;
669 (
unsigned long long) cx->
std);
676 static int cx18_s_tuner(
struct file *file,
void *fh,
struct v4l2_tuner *vt)
679 struct cx18 *cx =
id->cx;
688 static int cx18_g_tuner(
struct file *file,
void *fh,
struct v4l2_tuner *vt)
690 struct cx18 *cx = fh2id(fh)->cx;
704 static int cx18_g_sliced_vbi_cap(
struct file *file,
void *fh,
707 struct cx18 *cx = fh2id(fh)->cx;
715 for (f = 0; f < 2; f++) {
716 for (l = 0; l < 24; l++) {
717 if (valid_service_line(f, l, cx->
is_50hz)) {
728 for (f = 0; f < 3; f++)
736 int consumed, remaining;
782 consumed += remaining;
825 static int cx18_g_enc_index(
struct file *file,
void *fh,
828 struct cx18 *cx = fh2id(fh)->cx;
833 if (!cx18_stream_enabled(s))
855 cx18_process_idx_data(s, mdl, idx);
858 cx18_push(s, mdl, &s->
q_full);
863 cx18_enqueue(s, mdl, &s->
q_free);
868 cx18_stream_load_fw_queue(s);
875 struct cx18 *cx =
id->cx;
890 static int cx18_streamon(
struct file *file,
void *
priv,
894 struct cx18 *cx =
id->cx;
911 static int cx18_streamoff(
struct file *file,
void *priv,
915 struct cx18 *cx =
id->cx;
929 static int cx18_reqbufs(
struct file *file,
void *priv,
933 struct cx18 *cx =
id->cx;
943 static int cx18_querybuf(
struct file *file,
void *priv,
947 struct cx18 *cx =
id->cx;
957 static int cx18_qbuf(
struct file *file,
void *priv,
struct v4l2_buffer *b)
960 struct cx18 *cx =
id->cx;
970 static int cx18_dqbuf(
struct file *file,
void *priv,
struct v4l2_buffer *b)
973 struct cx18 *cx =
id->cx;
983 static int cx18_encoder_cmd(
struct file *file,
void *fh,
987 struct cx18 *cx =
id->cx;
1012 CX18_ERR(
"Can't find valid task handle for "
1013 "V4L2_ENC_CMD_PAUSE\n");
1029 CX18_ERR(
"Can't find valid task handle for "
1030 "V4L2_ENC_CMD_RESUME\n");
1044 static int cx18_try_encoder_cmd(
struct file *file,
void *fh,
1047 struct cx18 *cx = fh2id(fh)->cx;
1077 static int cx18_log_status(
struct file *file,
void *fh)
1079 struct cx18 *cx = fh2id(fh)->cx;
1093 CX18_INFO(
"Video Input: %s\n", vidin.name);
1094 CX18_INFO(
"Audio Input: %s\n", audin.name);
1096 CX18_INFO(
"GPIO: direction 0x%08x, value 0x%08x\n",
1108 CX18_INFO(
"Stream %s: status 0x%04lx, %d%% of %d KiB (%d buffers) in use\n",
1114 CX18_INFO(
"Read MPEG/VBI: %lld/%lld bytes\n",
1120 static long cx18_default(
struct file *file,
void *fh,
bool valid_prio,
1123 struct cx18 *cx = fh2id(fh)->cx;
1129 if ((val == 0) || (val & 0x01))
1142 .vidioc_querycap = cx18_querycap,
1143 .vidioc_s_audio = cx18_s_audio,
1144 .vidioc_g_audio = cx18_g_audio,
1145 .vidioc_enumaudio = cx18_enumaudio,
1146 .vidioc_enum_input = cx18_enum_input,
1147 .vidioc_cropcap = cx18_cropcap,
1148 .vidioc_s_crop = cx18_s_crop,
1149 .vidioc_g_crop = cx18_g_crop,
1150 .vidioc_g_input = cx18_g_input,
1152 .vidioc_g_frequency = cx18_g_frequency,
1154 .vidioc_s_tuner = cx18_s_tuner,
1155 .vidioc_g_tuner = cx18_g_tuner,
1156 .vidioc_g_enc_index = cx18_g_enc_index,
1157 .vidioc_g_std = cx18_g_std,
1159 .vidioc_log_status = cx18_log_status,
1160 .vidioc_enum_fmt_vid_cap = cx18_enum_fmt_vid_cap,
1161 .vidioc_encoder_cmd = cx18_encoder_cmd,
1162 .vidioc_try_encoder_cmd = cx18_try_encoder_cmd,
1163 .vidioc_g_fmt_vid_cap = cx18_g_fmt_vid_cap,
1164 .vidioc_g_fmt_vbi_cap = cx18_g_fmt_vbi_cap,
1165 .vidioc_g_fmt_sliced_vbi_cap = cx18_g_fmt_sliced_vbi_cap,
1166 .vidioc_s_fmt_vid_cap = cx18_s_fmt_vid_cap,
1167 .vidioc_s_fmt_vbi_cap = cx18_s_fmt_vbi_cap,
1168 .vidioc_s_fmt_sliced_vbi_cap = cx18_s_fmt_sliced_vbi_cap,
1169 .vidioc_try_fmt_vid_cap = cx18_try_fmt_vid_cap,
1170 .vidioc_try_fmt_vbi_cap = cx18_try_fmt_vbi_cap,
1171 .vidioc_try_fmt_sliced_vbi_cap = cx18_try_fmt_sliced_vbi_cap,
1172 .vidioc_g_sliced_vbi_cap = cx18_g_sliced_vbi_cap,
1173 .vidioc_g_chip_ident = cx18_g_chip_ident,
1174 #ifdef CONFIG_VIDEO_ADV_DEBUG
1175 .vidioc_g_register = cx18_g_register,
1176 .vidioc_s_register = cx18_s_register,
1178 .vidioc_default = cx18_default,
1179 .vidioc_streamon = cx18_streamon,
1180 .vidioc_streamoff = cx18_streamoff,
1181 .vidioc_reqbufs = cx18_reqbufs,
1182 .vidioc_querybuf = cx18_querybuf,
1183 .vidioc_qbuf = cx18_qbuf,
1184 .vidioc_dqbuf = cx18_dqbuf,