Lines Matching refs:dev

88 void cx23885_video_wakeup(struct cx23885_dev *dev,
106 int cx23885_set_tvnorm(struct cx23885_dev *dev, v4l2_std_id norm)
118 if (dev->tvnorm == norm)
121 if (dev->tvnorm != norm) {
122 if (vb2_is_busy(&dev->vb2_vidq) || vb2_is_busy(&dev->vb2_vbiq) ||
123 vb2_is_busy(&dev->vb2_mpegq))
127 dev->tvnorm = norm;
128 dev->width = 720;
129 dev->height = norm_maxh(norm);
130 dev->field = V4L2_FIELD_INTERLACED;
132 call_all(dev, video, s_std, norm);
134 format.format.width = dev->width;
135 format.format.height = dev->height;
136 format.format.field = dev->field;
137 call_all(dev, pad, set_fmt, NULL, &format);
142 static struct video_device *cx23885_vdev_init(struct cx23885_dev *dev,
154 vfd->v4l2_dev = &dev->v4l2_dev;
156 vfd->lock = &dev->lock;
158 cx23885_boards[dev->board].name, type);
159 video_set_drvdata(vfd, dev);
163 int cx23885_flatiron_write(struct cx23885_dev *dev, u8 reg, u8 data)
171 return i2c_transfer(&dev->i2c_bus[2].i2c_adap, &msg, 1);
174 u8 cx23885_flatiron_read(struct cx23885_dev *dev, u8 reg)
186 ret = i2c_transfer(&dev->i2c_bus[2].i2c_adap, &msg[0], 2);
193 static void cx23885_flatiron_dump(struct cx23885_dev *dev)
199 cx23885_flatiron_read(dev, i));
203 static int cx23885_flatiron_mux(struct cx23885_dev *dev, int input)
209 val = cx23885_flatiron_read(dev, CH_PWR_CTRL1) & ~FLD_CH_SEL;
211 val = cx23885_flatiron_read(dev, CH_PWR_CTRL1) | FLD_CH_SEL;
217 cx23885_flatiron_write(dev, CH_PWR_CTRL1, val);
220 cx23885_flatiron_write(dev, CH_PWR_CTRL2, 0);
223 cx23885_flatiron_dump(dev);
228 static int cx23885_video_mux(struct cx23885_dev *dev, unsigned int input)
235 dev->input = input;
237 if (dev->board == CX23885_BOARD_MYGICA_X8506 ||
238 dev->board == CX23885_BOARD_MAGICPRO_PROHDTVE2 ||
239 dev->board == CX23885_BOARD_MYGICA_X8507) {
242 cx23885_gpio_clear(dev, GPIO_0);
246 v4l2_subdev_call(dev->sd_cx25840, video, s_routing,
249 if ((dev->board == CX23885_BOARD_HAUPPAUGE_HVR1800) ||
250 (dev->board == CX23885_BOARD_MPX885) ||
251 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1250) ||
252 (dev->board == CX23885_BOARD_HAUPPAUGE_IMPACTVCBE) ||
253 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1255) ||
254 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1255_22111) ||
255 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1265_K4) ||
256 (dev->board == CX23885_BOARD_HAUPPAUGE_QUADHD_ATSC) ||
257 (dev->board == CX23885_BOARD_HAUPPAUGE_QUADHD_DVB) ||
258 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1850) ||
259 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR5525) ||
260 (dev->board == CX23885_BOARD_MYGICA_X8507) ||
261 (dev->board == CX23885_BOARD_AVERMEDIA_HC81R) ||
262 (dev->board == CX23885_BOARD_VIEWCAST_260E) ||
263 (dev->board == CX23885_BOARD_VIEWCAST_460E) ||
264 (dev->board == CX23885_BOARD_AVERMEDIA_CE310B)) {
266 v4l2_subdev_call(dev->sd_cx25840, audio, s_routing,
270 cx23885_flatiron_mux(dev, 1);
272 cx23885_flatiron_mux(dev, 2);
278 static int cx23885_audio_mux(struct cx23885_dev *dev, unsigned int input)
292 cx23885_flatiron_mux(dev, 1);
294 cx23885_flatiron_mux(dev, 2);
297 cx23885_flatiron_mux(dev, 1);
304 static int cx23885_start_video_dma(struct cx23885_dev *dev,
314 cx23885_sram_channel_setup(dev, &dev->sram_channels[SRAM_CH01],
322 cx23885_irq_add_enable(dev, 0x01);
336 struct cx23885_dev *dev = q->drv_priv;
339 sizes[0] = (dev->fmt->depth * dev->width * dev->height) >> 3;
346 struct cx23885_dev *dev = vb->vb2_queue->drv_priv;
353 buf->bpl = (dev->width * dev->fmt->depth) >> 3;
355 if (vb2_plane_size(vb, 0) < dev->height * buf->bpl)
357 vb2_set_plane_payload(vb, 0, dev->height * buf->bpl);
359 switch (dev->field) {
361 cx23885_risc_buffer(dev->pci, &buf->risc,
363 buf->bpl, 0, dev->height);
366 cx23885_risc_buffer(dev->pci, &buf->risc,
368 buf->bpl, 0, dev->height);
371 if (dev->tvnorm & V4L2_STD_525_60)
377 if (cx23885_boards[dev->board].force_bff)
394 cx23885_risc_buffer(dev->pci, &buf->risc,
398 dev->height >> 1);
401 cx23885_risc_buffer(dev->pci, &buf->risc,
403 0, buf->bpl * (dev->height >> 1),
405 dev->height >> 1);
408 cx23885_risc_buffer(dev->pci, &buf->risc,
410 buf->bpl * (dev->height >> 1), 0,
412 dev->height >> 1);
419 dev->width, dev->height, dev->fmt->depth, dev->fmt->fourcc,
457 struct cx23885_dev *dev = vb->vb2_queue->drv_priv;
461 struct cx23885_dmaqueue *q = &dev->vidq;
470 spin_lock_irqsave(&dev->slock, flags);
484 spin_unlock_irqrestore(&dev->slock, flags);
489 struct cx23885_dev *dev = q->drv_priv;
490 struct cx23885_dmaqueue *dmaq = &dev->vidq;
494 cx23885_start_video_dma(dev, dmaq, buf);
500 struct cx23885_dev *dev = q->drv_priv;
501 struct cx23885_dmaqueue *dmaq = &dev->vidq;
505 spin_lock_irqsave(&dev->slock, flags);
513 spin_unlock_irqrestore(&dev->slock, flags);
533 struct cx23885_dev *dev = video_drvdata(file);
535 f->fmt.pix.width = dev->width;
536 f->fmt.pix.height = dev->height;
537 f->fmt.pix.field = dev->field;
538 f->fmt.pix.pixelformat = dev->fmt->fourcc;
540 (f->fmt.pix.width * dev->fmt->depth) >> 3;
551 struct cx23885_dev *dev = video_drvdata(file);
562 maxh = norm_maxh(dev->tvnorm);
599 struct cx23885_dev *dev = video_drvdata(file);
611 if (vb2_is_busy(&dev->vb2_vidq) || vb2_is_busy(&dev->vb2_vbiq) ||
612 vb2_is_busy(&dev->vb2_mpegq))
615 dev->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
616 dev->width = f->fmt.pix.width;
617 dev->height = f->fmt.pix.height;
618 dev->field = f->fmt.pix.field;
620 dev->width, dev->height, dev->field);
622 call_all(dev, pad, set_fmt, NULL, &format);
625 f->fmt.pix.field = dev->field;
632 struct cx23885_dev *dev = video_drvdata(file);
635 strscpy(cap->card, cx23885_boards[dev->board].name,
637 sprintf(cap->bus_info, "PCIe:%s", pci_name(dev->pci));
642 switch (dev->board) { /* i2c device tuners */
650 if (dev->tuner_type != TUNER_ABSENT)
671 struct cx23885_dev *dev = video_drvdata(file);
672 bool is_50hz = dev->tvnorm & V4L2_STD_625_50;
686 struct cx23885_dev *dev = video_drvdata(file);
697 sel->r.height = norm_maxh(dev->tvnorm);
707 struct cx23885_dev *dev = video_drvdata(file);
710 *id = dev->tvnorm;
716 struct cx23885_dev *dev = video_drvdata(file);
719 return cx23885_set_tvnorm(dev, tvnorms);
722 int cx23885_enum_input(struct cx23885_dev *dev, struct v4l2_input *i)
759 if (dev->input == n) {
765 call_all(dev, video, g_input_status, &i->status);
774 struct cx23885_dev *dev = video_drvdata(file);
776 return cx23885_enum_input(dev, i);
781 struct cx23885_dev *dev = video_drvdata(file);
783 *i = dev->input;
795 struct cx23885_dev *dev = video_drvdata(file);
807 cx23885_video_mux(dev, i);
811 cx23885_audio_mux(dev, i);
822 struct cx23885_dev *dev = video_drvdata(file);
824 call_all(dev, core, log_status);
860 struct cx23885_dev *dev = video_drvdata(file);
862 if ((CX23885_VMUX_TELEVISION == INPUT(dev->input)->type) ||
863 (CX23885_VMUX_CABLE == INPUT(dev->input)->type))
866 i->index = dev->audinput;
875 struct cx23885_dev *dev = video_drvdata(file);
877 if ((CX23885_VMUX_TELEVISION == INPUT(dev->input)->type) ||
878 (CX23885_VMUX_CABLE == INPUT(dev->input)->type)) {
886 dev->audinput = i->index;
890 cx23885_flatiron_mux(dev, dev->audinput + 1);
897 struct cx23885_dev *dev = video_drvdata(file);
899 switch (dev->board) { /* i2c device tuners */
906 if (dev->tuner_type == TUNER_ABSENT)
915 call_all(dev, tuner, g_tuner, t);
922 struct cx23885_dev *dev = video_drvdata(file);
924 switch (dev->board) { /* i2c device tuners */
931 if (dev->tuner_type == TUNER_ABSENT)
938 call_all(dev, tuner, s_tuner, t);
946 struct cx23885_dev *dev = video_drvdata(file);
948 switch (dev->board) { /* i2c device tuners */
955 if (dev->tuner_type == TUNER_ABSENT)
960 f->frequency = dev->freq;
962 call_all(dev, tuner, g_frequency, f);
967 static int cx23885_set_freq(struct cx23885_dev *dev, const struct v4l2_frequency *f)
972 switch (dev->board) { /* i2c device tuners */
979 if (dev->tuner_type == TUNER_ABSENT)
986 dev->freq = f->frequency;
989 mute = v4l2_ctrl_find(&dev->ctrl_handler, V4L2_CID_AUDIO_MUTE);
996 call_all(dev, tuner, s_frequency, f);
1008 static int cx23885_set_freq_via_ops(struct cx23885_dev *dev,
1019 .std = dev->tvnorm,
1023 dev->freq = f->frequency;
1026 mute = v4l2_ctrl_find(&dev->ctrl_handler, V4L2_CID_AUDIO_MUTE);
1037 vfe = vb2_dvb_get_frontend(&dev->ts2.frontends, 1);
1044 if ((dev->board == CX23885_BOARD_HAUPPAUGE_HVR1850) ||
1045 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1255) ||
1046 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1255_22111) ||
1047 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1265_K4) ||
1048 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR5525) ||
1049 (dev->board == CX23885_BOARD_HAUPPAUGE_QUADHD_DVB) ||
1050 (dev->board == CX23885_BOARD_HAUPPAUGE_QUADHD_ATSC))
1051 fe = &dev->ts1.analog_fe;
1054 call_all(dev, video, s_std, dev->tvnorm);
1073 struct cx23885_dev *dev = video_drvdata(file);
1076 switch (dev->board) {
1084 ret = cx23885_set_freq_via_ops(dev, f);
1087 ret = cx23885_set_freq(dev, f);
1101 int cx23885_video_irq(struct cx23885_dev *dev, u32 status)
1121 dev->name);
1122 cx23885_sram_channel_dump(dev,
1123 &dev->sram_channels[SRAM_CH01]);
1138 spin_lock(&dev->slock);
1140 cx23885_video_wakeup(dev, &dev->vidq, count);
1141 spin_unlock(&dev->slock);
1146 handled += cx23885_vbi_irq(dev, status);
1212 void cx23885_video_unregister(struct cx23885_dev *dev)
1215 cx23885_irq_remove(dev, 0x01);
1217 if (dev->vbi_dev) {
1218 if (video_is_registered(dev->vbi_dev))
1219 video_unregister_device(dev->vbi_dev);
1221 video_device_release(dev->vbi_dev);
1222 dev->vbi_dev = NULL;
1224 if (dev->video_dev) {
1225 if (video_is_registered(dev->video_dev))
1226 video_unregister_device(dev->video_dev);
1228 video_device_release(dev->video_dev);
1229 dev->video_dev = NULL;
1232 if (dev->audio_dev)
1233 cx23885_audio_unregister(dev);
1236 int cx23885_video_register(struct cx23885_dev *dev)
1248 dev->tvnorm = V4L2_STD_NTSC_M;
1249 dev->fmt = format_by_fourcc(V4L2_PIX_FMT_YUYV);
1250 dev->field = V4L2_FIELD_INTERLACED;
1251 dev->width = 720;
1252 dev->height = norm_maxh(dev->tvnorm);
1255 INIT_LIST_HEAD(&dev->vidq.active);
1258 INIT_LIST_HEAD(&dev->vbiq.active);
1260 cx23885_irq_add_enable(dev, 0x01);
1262 if ((TUNER_ABSENT != dev->tuner_type) &&
1263 ((dev->tuner_bus == 0) || (dev->tuner_bus == 1))) {
1266 if (dev->tuner_addr)
1267 sd = v4l2_i2c_new_subdev(&dev->v4l2_dev,
1268 &dev->i2c_bus[dev->tuner_bus].i2c_adap,
1269 "tuner", dev->tuner_addr, NULL);
1271 sd = v4l2_i2c_new_subdev(&dev->v4l2_dev,
1272 &dev->i2c_bus[dev->tuner_bus].i2c_adap,
1279 tun_setup.type = dev->tuner_type;
1285 if ((dev->board == CX23885_BOARD_LEADTEK_WINFAST_PXTV1200) ||
1286 (dev->board == CX23885_BOARD_LEADTEK_WINFAST_PXPVR2200)) {
1292 .tuner = dev->tuner_type,
1298 if (dev->board == CX23885_BOARD_AVERMEDIA_HC81R) {
1304 .tuner = dev->tuner_type,
1313 mutex_lock(&dev->lock);
1314 cx23885_set_tvnorm(dev, dev->tvnorm);
1315 cx23885_video_mux(dev, 0);
1316 cx23885_audio_mux(dev, 0);
1317 mutex_unlock(&dev->lock);
1319 q = &dev->vb2_vidq;
1324 q->drv_priv = dev;
1329 q->lock = &dev->lock;
1330 q->dev = &dev->pci->dev;
1336 q = &dev->vb2_vbiq;
1341 q->drv_priv = dev;
1346 q->lock = &dev->lock;
1347 q->dev = &dev->pci->dev;
1354 dev->video_dev = cx23885_vdev_init(dev, dev->pci,
1356 dev->video_dev->queue = &dev->vb2_vidq;
1357 dev->video_dev->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING |
1359 switch (dev->board) { /* i2c device tuners */
1364 dev->video_dev->device_caps |= V4L2_CAP_TUNER;
1367 if (dev->tuner_type != TUNER_ABSENT)
1368 dev->video_dev->device_caps |= V4L2_CAP_TUNER;
1371 err = video_register_device(dev->video_dev, VFL_TYPE_VIDEO,
1372 video_nr[dev->nr]);
1375 dev->name);
1379 dev->name, video_device_node_name(dev->video_dev));
1382 dev->vbi_dev = cx23885_vdev_init(dev, dev->pci,
1384 dev->vbi_dev->queue = &dev->vb2_vbiq;
1385 dev->vbi_dev->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING |
1387 switch (dev->board) { /* i2c device tuners */
1392 dev->vbi_dev->device_caps |= V4L2_CAP_TUNER;
1395 if (dev->tuner_type != TUNER_ABSENT)
1396 dev->vbi_dev->device_caps |= V4L2_CAP_TUNER;
1398 err = video_register_device(dev->vbi_dev, VFL_TYPE_VBI,
1399 vbi_nr[dev->nr]);
1402 dev->name);
1406 dev->name, video_device_node_name(dev->vbi_dev));
1409 dev->audio_dev = cx23885_audio_register(dev);
1414 cx23885_video_unregister(dev);