34 static const u32 saa7164_v4l2_ctrls[] = {
120 params->
pitch = 1600;
121 params->
pitch = 1440;
131 for (i = 0; i < port->
hwcfg.buffercount; i++) {
138 "(errno = %d), unable to allocate buffer\n",
179 static int saa7164_vbi_initialize(
struct saa7164_port *port)
181 saa7164_vbi_configure(port);
195 for (i = 0; i <
ARRAY_SIZE(saa7164_tvnorms); i++) {
196 if (*
id & saa7164_tvnorms[i].
id)
214 static int vidioc_enum_input(
struct file *file,
void *priv,
219 char *inputs[] = {
"tuner",
"composite",
"svideo",
"aux",
220 "composite 2",
"svideo 2",
"aux 2" };
232 for (n = 0; n <
ARRAY_SIZE(saa7164_tvnorms); n++)
233 i->
std |= saa7164_tvnorms[n].
id;
238 static int vidioc_g_input(
struct file *file,
void *priv,
unsigned int *i)
254 static int vidioc_s_input(
struct file *file,
void *priv,
unsigned int i)
273 static int vidioc_g_tuner(
struct file *file,
void *priv,
292 static int vidioc_s_tuner(
struct file *file,
void *priv,
299 static int vidioc_g_frequency(
struct file *file,
void *priv,
311 static int vidioc_s_frequency(
struct file *file,
void *priv,
349 fe = tsport->
dvb.frontend;
351 if (fe && fe->
ops.tuner_ops.set_analog_params)
352 fe->
ops.tuner_ops.set_analog_params(fe, ¶ms);
356 saa7164_vbi_initialize(port);
361 static int vidioc_g_ctrl(
struct file *file,
void *priv,
397 static int vidioc_s_ctrl(
struct file *file,
void *priv,
410 if ((ctl->
value >= 0) && (ctl->
value <= 255)) {
418 if ((ctl->
value >= 0) && (ctl->
value <= 255)) {
425 if ((ctl->
value >= 0) && (ctl->
value <= 255)) {
433 if ((ctl->
value >= 0) && (ctl->
value <= 255)) {
440 if ((ctl->
value >= 0) && (ctl->
value <= 255)) {
447 if ((ctl->
value >= -83) && (ctl->
value <= 24)) {
487 static int vidioc_g_ext_ctrls(
struct file *file,
void *priv,
495 for (i = 0; i < ctrls->
count; i++) {
498 err = saa7164_get_ctrl(port, ctrl);
522 if ((ctrl->
value >= 0) &&
532 if ((ctrl->
value >= 0) &&
533 (ctrl->
value <= 255))
537 if ((ctrl->
value >= 1) &&
548 static int vidioc_try_ext_ctrls(
struct file *file,
void *priv,
554 for (i = 0; i < ctrls->
count; i++) {
557 err = saa7164_try_ctrl(ctrl, 0);
612 static int vidioc_s_ext_ctrls(
struct file *file,
void *priv,
620 for (i = 0; i < ctrls->
count; i++) {
623 err = saa7164_try_ctrl(ctrl, 0);
628 err = saa7164_set_ctrl(port, ctrl);
641 static int vidioc_querycap(
struct file *file,
void *priv,
664 static int vidioc_enum_fmt_vid_cap(
struct file *file,
void *priv,
676 static int vidioc_g_fmt_vid_cap(
struct file *file,
void *priv,
684 f->
fmt.
pix.bytesperline = 0;
687 f->
fmt.
pix.colorspace = 0;
697 static int vidioc_try_fmt_vid_cap(
struct file *file,
void *priv,
705 f->
fmt.
pix.bytesperline = 0;
708 f->
fmt.
pix.colorspace = 0;
714 static int vidioc_s_fmt_vid_cap(
struct file *file,
void *priv,
722 f->
fmt.
pix.bytesperline = 0;
725 f->
fmt.
pix.colorspace = 0;
771 static int vidioc_queryctrl(
struct file *file,
void *priv,
784 for (i = 0; i <
ARRAY_SIZE(saa7164_v4l2_ctrls); i++) {
786 if (c->
id < saa7164_v4l2_ctrls[i])
787 c->
id = saa7164_v4l2_ctrls[
i];
792 if (c->
id == saa7164_v4l2_ctrls[i])
795 if (c->
id < saa7164_v4l2_ctrls[i])
802 static int saa7164_vbi_stop_port(
struct saa7164_port *port)
820 static int saa7164_vbi_acquire_port(
struct saa7164_port *port)
838 static int saa7164_vbi_pause_port(
struct saa7164_port *port)
862 static int saa7164_vbi_stop_streaming(
struct saa7164_port *port)
872 ret = saa7164_vbi_pause_port(port);
873 ret = saa7164_vbi_acquire_port(port);
874 ret = saa7164_vbi_stop_port(port);
898 saa7164_vbi_buffers_dealloc(port);
905 static int saa7164_vbi_start_streaming(
struct saa7164_port *port)
918 saa7164_vbi_buffers_alloc(port);
954 result = saa7164_vbi_stop_port(port);
957 "failed, res = 0x%x\n", __func__, result);
972 result = saa7164_vbi_acquire_port(port);
973 result = saa7164_vbi_stop_port(port);
976 "failed, res = 0x%x\n", __func__, result);
990 f->
fmt.
vbi.samples_per_line = 1600;
991 f->
fmt.
vbi.samples_per_line = 1440;
992 f->
fmt.
vbi.sampling_rate = 27000000;
998 f->
fmt.
vbi.start[1] = 263 + 10 + 1;
1003 static int fops_open(
struct file *file)
1028 static int fops_release(
struct file *file)
1040 saa7164_vbi_stop_streaming(port);
1063 if (crc != ubuf->
crc) {
1064 printk(
KERN_ERR "%s() ubuf %p crc became invalid, was 0x%x became 0x%x\n",
1066 ubuf, ubuf->
crc, crc);
1078 static ssize_t fops_read(
struct file *file,
char __user *
buffer,
1105 if (saa7164_vbi_initialize(port) < 0) {
1110 saa7164_vbi_start_streaming(port);
1127 while ((count > 0) && ubuf) {
1131 cnt = rem > count ? count : rem;
1136 "%s() count=%d cnt=%d rem=%d buf=%p buf->pos=%d\n",
1137 __func__, (
int)count, cnt, rem, ubuf, ubuf->
pos);
1178 if (!ret && !ubuf) {
1186 static unsigned int fops_poll(
struct file *file,
poll_table *
wait)
1190 unsigned int mask = 0;
1205 if (saa7164_vbi_initialize(port) < 0)
1207 saa7164_vbi_start_streaming(port);
1229 .release = fops_release,
1258 #ifdef CONFIG_VIDEO_ADV_DEBUG
1272 .ioctl_ops = &vbi_ioctl_ops,
1313 if (port->
hwcfg.BARLocation == 0) {
1315 "(errno = %d), NO PCI configuration\n",
1325 dev->
pci, &saa7164_vbi_template,
"vbi");
1335 result = video_register_device(port->
v4l_device,