46 struct ivtv *itv =
id->itv;
53 if (s->
fh == &id->
fh) {
83 itv->
vbi.insert_mpeg && !ivtv_raw_vbi(itv)) {
88 s_vbi = &itv->
streams[vbi_type];
152 static void ivtv_dualwatch(
struct ivtv *
itv)
159 memset(&vt, 0,
sizeof(vt));
162 new_stereo_mode = dual;
173 static void ivtv_update_pgm_info(
struct ivtv *itv)
216 ivtv_update_pgm_info(itv);
233 buf = &itv->
vbi.sliced_mpeg_buf;
289 static void ivtv_setup_sliced_vbi_buf(
struct ivtv *itv)
293 itv->
vbi.sliced_mpeg_buf.buf = itv->
vbi.sliced_mpeg_data[
idx];
294 itv->
vbi.sliced_mpeg_buf.bytesused = itv->
vbi.sliced_mpeg_size[
idx];
295 itv->
vbi.sliced_mpeg_buf.readpos = 0;
299 char __user *ubuf,
size_t ucount)
304 if (len > ucount) len = ucount;
306 !ivtv_raw_vbi(itv) && buf != &itv->
vbi.sliced_mpeg_buf) {
308 const char *
p = start + 1;
313 while (start + len > p && (q =
memchr(p, 0, start + len - p))) {
316 q[1] != 0 || q[2] != 1 || q[3] != ch) {
320 if ((q[6] & 0xc0) != 0x80)
322 if (((q[7] & 0xc0) == 0x80 && (q[9] & 0xf0) == 0x20) ||
323 ((q[7] & 0xc0) == 0xc0 && (q[9] & 0xf0) == 0x30)) {
330 stuffing = q[13] & 7;
332 for (i = 0; i < stuffing; i++)
333 if (q[14 + i] != 0xff)
335 if (i == stuffing && (q[4] & 0xc4) == 0x44 && (q[12] & 3) == 3 &&
336 q[14 + stuffing] == 0 && q[15 + stuffing] == 0 &&
337 q[16 + stuffing] == 1) {
339 len = (
char *)q - start;
340 ivtv_setup_sliced_vbi_buf(itv);
358 static ssize_t ivtv_read(
struct ivtv_stream *s,
char __user *ubuf,
size_t tot_count,
int non_block)
361 size_t tot_written = 0;
362 int single_frame = 0;
380 buf = ivtv_get_buffer(s, non_block, &rc);
395 rc = ivtv_copy_buf_to_user(s, buf, ubuf + tot_written, tot_count - tot_written);
396 if (buf != &itv->
vbi.sliced_mpeg_buf) {
401 itv->
vbi.sliced_mpeg_size[
idx] = 0;
402 itv->
vbi.inserted_frame++;
409 if (tot_written == tot_count || single_frame)
416 loff_t *
pos,
int non_block)
418 ssize_t rc = count ? ivtv_read(s, ubuf, count, non_block) : 0;
429 struct ivtv *itv =
id->itv;
508 struct ivtv *itv =
id->itv;
525 struct ivtv *itv =
id->itv;
548 static ssize_t ivtv_write(
struct file *filp,
const char __user *user_buf,
size_t count, loff_t *pos)
551 struct ivtv *itv =
id->itv;
556 int bytes_written = 0;
618 return bytes_written;
696 while (!(got_sig = signal_pending(
current)) &&
717 return bytes_written;
723 struct ivtv *itv =
id->itv;
728 res = ivtv_write(filp, user_buf, count, pos);
736 struct ivtv *itv =
id->itv;
745 if (!list_empty(&id->
fh.subscribed)) {
746 poll_wait(filp, &id->
fh.wait, wait);
754 poll_wait(filp, &s->
waitq, wait);
769 unsigned long req_events = poll_requested_events(wait);
771 struct ivtv *itv =
id->itv;
795 poll_wait(filp, &s->
waitq, wait);
799 poll_wait(filp, &id->
fh.wait, wait);
810 struct ivtv *itv =
id->itv;
849 struct ivtv *itv =
id->itv;
882 struct ivtv *itv =
id->itv;
891 v4l2_fh_is_singular_file(filp)) {
918 if (s->
fh != &id->
fh)
943 static int ivtv_open(
struct file *filp)
954 IVTV_ERR(
"Failed to initialize on device %s\n",
955 video_device_node_name(vdev));
959 #ifdef CONFIG_VIDEO_ADV_DEBUG
962 IVTV_WARN(
"Opening %s with dead firmware lockout disabled\n",
963 video_device_node_name(vdev));
964 IVTV_WARN(
"Selected firmware errors will be ignored\n");
986 IVTV_ERR(
"Tried to open YUV output device but need to send data to mpeg decoder before it can be used\n");
1006 v4l2_fh_is_singular_file(filp)) {
1040 1080 * ((itv->
yuv_info.v4l2_src_h + 31) & ~31);
1053 res = ivtv_open(filp);