Lines Matching refs:dev

54 		dev_printk(KERN_DEBUG, &dev->intf->dev,			\
60 dev_printk(KERN_DEBUG, &dev->intf->dev, \
126 static inline unsigned int norm_maxw(struct em28xx *dev) in norm_maxw() argument
128 struct em28xx_v4l2 *v4l2 = dev->v4l2; in norm_maxw()
130 if (dev->is_webcam) in norm_maxw()
133 if (dev->board.max_range_640_480) in norm_maxw()
139 static inline unsigned int norm_maxh(struct em28xx *dev) in norm_maxh() argument
141 struct em28xx_v4l2 *v4l2 = dev->v4l2; in norm_maxh()
143 if (dev->is_webcam) in norm_maxh()
146 if (dev->board.max_range_640_480) in norm_maxh()
152 static int em28xx_vbi_supported(struct em28xx *dev) in em28xx_vbi_supported() argument
158 if (dev->is_webcam) in em28xx_vbi_supported()
163 if (dev->chip_id == CHIP_ID_EM2860 || in em28xx_vbi_supported()
164 dev->chip_id == CHIP_ID_EM2883) in em28xx_vbi_supported()
175 static void em28xx_wake_i2c(struct em28xx *dev) in em28xx_wake_i2c() argument
177 struct v4l2_device *v4l2_dev = &dev->v4l2->v4l2_dev; in em28xx_wake_i2c()
181 INPUT(dev->ctl_input)->vmux, 0, 0); in em28xx_wake_i2c()
184 static int em28xx_colorlevels_set_default(struct em28xx *dev) in em28xx_colorlevels_set_default() argument
186 em28xx_write_reg(dev, EM28XX_R20_YGAIN, CONTRAST_DEFAULT); in em28xx_colorlevels_set_default()
187 em28xx_write_reg(dev, EM28XX_R21_YOFFSET, BRIGHTNESS_DEFAULT); in em28xx_colorlevels_set_default()
188 em28xx_write_reg(dev, EM28XX_R22_UVGAIN, SATURATION_DEFAULT); in em28xx_colorlevels_set_default()
189 em28xx_write_reg(dev, EM28XX_R23_UOFFSET, BLUE_BALANCE_DEFAULT); in em28xx_colorlevels_set_default()
190 em28xx_write_reg(dev, EM28XX_R24_VOFFSET, RED_BALANCE_DEFAULT); in em28xx_colorlevels_set_default()
191 em28xx_write_reg(dev, EM28XX_R25_SHARPNESS, SHARPNESS_DEFAULT); in em28xx_colorlevels_set_default()
193 em28xx_write_reg(dev, EM28XX_R14_GAMMA, 0x20); in em28xx_colorlevels_set_default()
194 em28xx_write_reg(dev, EM28XX_R15_RGAIN, 0x20); in em28xx_colorlevels_set_default()
195 em28xx_write_reg(dev, EM28XX_R16_GGAIN, 0x20); in em28xx_colorlevels_set_default()
196 em28xx_write_reg(dev, EM28XX_R17_BGAIN, 0x20); in em28xx_colorlevels_set_default()
197 em28xx_write_reg(dev, EM28XX_R18_ROFFSET, 0x00); in em28xx_colorlevels_set_default()
198 em28xx_write_reg(dev, EM28XX_R19_GOFFSET, 0x00); in em28xx_colorlevels_set_default()
199 return em28xx_write_reg(dev, EM28XX_R1A_BOFFSET, 0x00); in em28xx_colorlevels_set_default()
202 static int em28xx_set_outfmt(struct em28xx *dev) in em28xx_set_outfmt() argument
206 struct em28xx_v4l2 *v4l2 = dev->v4l2; in em28xx_set_outfmt()
209 if (!dev->is_em25xx) in em28xx_set_outfmt()
220 ret = em28xx_write_reg(dev, EM28XX_R27_OUTFMT, fmt); in em28xx_set_outfmt()
224 ret = em28xx_write_reg(dev, EM28XX_R10_VINMODE, v4l2->vinmode); in em28xx_set_outfmt()
229 if (em28xx_vbi_supported(dev) == 1) { in em28xx_set_outfmt()
231 em28xx_write_reg(dev, EM28XX_R34_VBI_START_H, 0x00); in em28xx_set_outfmt()
232 em28xx_write_reg(dev, EM28XX_R36_VBI_WIDTH, in em28xx_set_outfmt()
234 em28xx_write_reg(dev, EM28XX_R37_VBI_HEIGHT, v4l2->vbi_height); in em28xx_set_outfmt()
237 em28xx_write_reg(dev, EM28XX_R35_VBI_START_V, 0x09); in em28xx_set_outfmt()
240 em28xx_write_reg(dev, EM28XX_R35_VBI_START_V, 0x07); in em28xx_set_outfmt()
244 return em28xx_write_reg(dev, EM28XX_R11_VINCTRL, vinctrl); in em28xx_set_outfmt()
247 static int em28xx_accumulator_set(struct em28xx *dev, u8 xmin, u8 xmax, in em28xx_accumulator_set() argument
253 em28xx_write_regs(dev, EM28XX_R28_XMIN, &xmin, 1); in em28xx_accumulator_set()
254 em28xx_write_regs(dev, EM28XX_R29_XMAX, &xmax, 1); in em28xx_accumulator_set()
255 em28xx_write_regs(dev, EM28XX_R2A_YMIN, &ymin, 1); in em28xx_accumulator_set()
256 return em28xx_write_regs(dev, EM28XX_R2B_YMAX, &ymax, 1); in em28xx_accumulator_set()
259 static void em28xx_capture_area_set(struct em28xx *dev, u8 hstart, u8 vstart, in em28xx_capture_area_set() argument
272 em28xx_write_regs(dev, EM28XX_R1C_HSTART, &hstart, 1); in em28xx_capture_area_set()
273 em28xx_write_regs(dev, EM28XX_R1D_VSTART, &vstart, 1); in em28xx_capture_area_set()
274 em28xx_write_regs(dev, EM28XX_R1E_CWIDTH, &cwidth, 1); in em28xx_capture_area_set()
275 em28xx_write_regs(dev, EM28XX_R1F_CHEIGHT, &cheight, 1); in em28xx_capture_area_set()
276 em28xx_write_regs(dev, EM28XX_R1B_OFLOW, &overflow, 1); in em28xx_capture_area_set()
280 if (dev->is_em25xx) { in em28xx_capture_area_set()
281 em28xx_write_reg(dev, 0x34, width >> 4); in em28xx_capture_area_set()
282 em28xx_write_reg(dev, 0x35, height >> 4); in em28xx_capture_area_set()
286 static int em28xx_scaler_set(struct em28xx *dev, u16 h, u16 v) in em28xx_scaler_set() argument
291 if (dev->board.is_em2800) { in em28xx_scaler_set()
298 em28xx_write_regs(dev, EM28XX_R30_HSCALELOW, (char *)buf, 2); in em28xx_scaler_set()
302 em28xx_write_regs(dev, EM28XX_R32_VSCALELOW, (char *)buf, 2); in em28xx_scaler_set()
309 return em28xx_write_reg(dev, EM28XX_R26_COMPR, mode); in em28xx_scaler_set()
313 static int em28xx_resolution_set(struct em28xx *dev) in em28xx_resolution_set() argument
315 struct em28xx_v4l2 *v4l2 = dev->v4l2; in em28xx_resolution_set()
316 int width = norm_maxw(dev); in em28xx_resolution_set()
317 int height = norm_maxh(dev); in em28xx_resolution_set()
326 em28xx_set_outfmt(dev); in em28xx_resolution_set()
328 em28xx_accumulator_set(dev, 1, (width - 4) >> 2, 1, (height - 4) >> 2); in em28xx_resolution_set()
339 if (em28xx_vbi_supported(dev) == 1) in em28xx_resolution_set()
340 em28xx_capture_area_set(dev, 0, 2, width, height); in em28xx_resolution_set()
342 em28xx_capture_area_set(dev, 0, 0, width, height); in em28xx_resolution_set()
344 return em28xx_scaler_set(dev, v4l2->hscale, v4l2->vscale); in em28xx_resolution_set()
348 static int em28xx_set_alternate(struct em28xx *dev) in em28xx_set_alternate() argument
350 struct em28xx_v4l2 *v4l2 = dev->v4l2; in em28xx_set_alternate()
351 struct usb_device *udev = interface_to_usbdev(dev->intf); in em28xx_set_alternate()
360 dev->alt = 0; in em28xx_set_alternate()
361 if (alt > 0 && alt < dev->num_alt) { in em28xx_set_alternate()
362 em28xx_videodbg("alternate forced to %d\n", dev->alt); in em28xx_set_alternate()
363 dev->alt = alt; in em28xx_set_alternate()
366 if (dev->analog_xfer_bulk) in em28xx_set_alternate()
377 for (i = 0; i < dev->num_alt; i++) { in em28xx_set_alternate()
379 if (dev->alt_max_pkt_size_isoc[i] >= min_pkt_size) { in em28xx_set_alternate()
380 dev->alt = i; in em28xx_set_alternate()
387 } else if (dev->alt_max_pkt_size_isoc[i] > in em28xx_set_alternate()
388 dev->alt_max_pkt_size_isoc[dev->alt]) in em28xx_set_alternate()
389 dev->alt = i; in em28xx_set_alternate()
398 if (dev->analog_xfer_bulk) { in em28xx_set_alternate()
399 dev->max_pkt_size = 512; /* USB 2.0 spec */ in em28xx_set_alternate()
400 dev->packet_multiplier = EM28XX_BULK_PACKET_MULTIPLIER; in em28xx_set_alternate()
403 min_pkt_size, dev->alt); in em28xx_set_alternate()
404 dev->max_pkt_size = in em28xx_set_alternate()
405 dev->alt_max_pkt_size_isoc[dev->alt]; in em28xx_set_alternate()
406 dev->packet_multiplier = EM28XX_NUM_ISOC_PACKETS; in em28xx_set_alternate()
409 dev->alt, dev->max_pkt_size); in em28xx_set_alternate()
410 err = usb_set_interface(udev, dev->ifnum, dev->alt); in em28xx_set_alternate()
412 dev_err(&dev->intf->dev, in em28xx_set_alternate()
414 dev->alt, err); in em28xx_set_alternate()
427 static inline void finish_buffer(struct em28xx *dev, in finish_buffer() argument
432 buf->vb.sequence = dev->v4l2->field_count++; in finish_buffer()
433 if (dev->v4l2->progressive) in finish_buffer()
445 static void em28xx_copy_video(struct em28xx *dev, in em28xx_copy_video() argument
450 struct em28xx_v4l2 *v4l2 = dev->v4l2; in em28xx_copy_video()
526 static void em28xx_copy_vbi(struct em28xx *dev, in em28xx_copy_vbi() argument
539 offset += dev->v4l2->vbi_width * dev->v4l2->vbi_height; in em28xx_copy_vbi()
545 static inline void print_err_status(struct em28xx *dev, in print_err_status() argument
587 static inline struct em28xx_buffer *get_next_buf(struct em28xx *dev, in get_next_buf() argument
611 finish_field_prepare_next(struct em28xx *dev, in finish_field_prepare_next() argument
615 struct em28xx_v4l2 *v4l2 = dev->v4l2; in finish_field_prepare_next()
619 finish_buffer(dev, buf); in finish_field_prepare_next()
620 buf = get_next_buf(dev, dma_q); in finish_field_prepare_next()
633 static inline void process_frame_data_em28xx(struct em28xx *dev, in process_frame_data_em28xx() argument
637 struct em28xx_v4l2 *v4l2 = dev->v4l2; in process_frame_data_em28xx()
638 struct em28xx_buffer *buf = dev->usb_ctl.vid_buf; in process_frame_data_em28xx()
639 struct em28xx_buffer *vbi_buf = dev->usb_ctl.vbi_buf; in process_frame_data_em28xx()
640 struct em28xx_dmaqueue *dma_q = &dev->vidq; in process_frame_data_em28xx()
641 struct em28xx_dmaqueue *vbi_dma_q = &dev->vbiq; in process_frame_data_em28xx()
682 vbi_buf = finish_field_prepare_next(dev, vbi_buf, vbi_dma_q); in process_frame_data_em28xx()
683 dev->usb_ctl.vbi_buf = vbi_buf; in process_frame_data_em28xx()
694 em28xx_copy_vbi(dev, vbi_buf, data_pkt, vbi_data_len); in process_frame_data_em28xx()
706 buf = finish_field_prepare_next(dev, buf, dma_q); in process_frame_data_em28xx()
707 dev->usb_ctl.vid_buf = buf; in process_frame_data_em28xx()
712 em28xx_copy_video(dev, buf, data_pkt, data_len); in process_frame_data_em28xx()
718 static inline void process_frame_data_em25xx(struct em28xx *dev, in process_frame_data_em25xx() argument
722 struct em28xx_buffer *buf = dev->usb_ctl.vid_buf; in process_frame_data_em25xx()
723 struct em28xx_dmaqueue *dmaq = &dev->vidq; in process_frame_data_em25xx()
724 struct em28xx_v4l2 *v4l2 = dev->v4l2; in process_frame_data_em25xx()
744 if (dev->analog_xfer_bulk && frame_end) { in process_frame_data_em25xx()
745 buf = finish_field_prepare_next(dev, buf, dmaq); in process_frame_data_em25xx()
746 dev->usb_ctl.vid_buf = buf; in process_frame_data_em25xx()
757 em28xx_copy_video(dev, buf, data_pkt, data_len); in process_frame_data_em25xx()
760 if (!dev->analog_xfer_bulk && frame_end) { in process_frame_data_em25xx()
761 buf = finish_field_prepare_next(dev, buf, dmaq); in process_frame_data_em25xx()
762 dev->usb_ctl.vid_buf = buf; in process_frame_data_em25xx()
779 static inline int em28xx_urb_data_copy(struct em28xx *dev, struct urb *urb) in em28xx_urb_data_copy() argument
785 if (!dev) in em28xx_urb_data_copy()
788 if (dev->disconnected) in em28xx_urb_data_copy()
792 print_err_status(dev, -1, urb->status); in em28xx_urb_data_copy()
808 print_err_status(dev, i, in em28xx_urb_data_copy()
815 if (usb_data_len > dev->max_pkt_size) { in em28xx_urb_data_copy()
830 if (dev->is_em25xx) in em28xx_urb_data_copy()
831 process_frame_data_em25xx(dev, in em28xx_urb_data_copy()
834 process_frame_data_em28xx(dev, in em28xx_urb_data_copy()
854 static int res_get(struct em28xx *dev, enum v4l2_buf_type f_type) in res_get() argument
859 if (dev->resources & res_type) { in res_get()
865 dev->resources |= res_type; in res_get()
870 static void res_free(struct em28xx *dev, enum v4l2_buf_type f_type) in res_free() argument
874 dev->resources &= ~res_type; in res_free()
878 static void em28xx_v4l2_media_release(struct em28xx *dev) in em28xx_v4l2_media_release() argument
886 media_device_unregister_entity(&dev->input_ent[i]); in em28xx_v4l2_media_release()
895 static int em28xx_enable_analog_tuner(struct em28xx *dev) in em28xx_enable_analog_tuner() argument
898 struct media_device *mdev = dev->media_dev; in em28xx_enable_analog_tuner()
899 struct em28xx_v4l2 *v4l2 = dev->v4l2; in em28xx_enable_analog_tuner()
938 dev_err(&dev->intf->dev, in em28xx_enable_analog_tuner()
961 static void em28xx_v4l2_create_entities(struct em28xx *dev) in em28xx_v4l2_create_entities() argument
964 struct em28xx_v4l2 *v4l2 = dev->v4l2; in em28xx_v4l2_create_entities()
971 dev_err(&dev->intf->dev, in em28xx_v4l2_create_entities()
974 if (em28xx_vbi_supported(dev)) { in em28xx_v4l2_create_entities()
979 dev_err(&dev->intf->dev, in em28xx_v4l2_create_entities()
984 if (dev->is_webcam) in em28xx_v4l2_create_entities()
989 struct media_entity *ent = &dev->input_ent[i]; in em28xx_v4l2_create_entities()
996 dev->input_pad[i].flags = MEDIA_PAD_FL_SOURCE; in em28xx_v4l2_create_entities()
1006 if (dev->tuner_type != TUNER_ABSENT) in em28xx_v4l2_create_entities()
1011 ret = media_entity_pads_init(ent, 1, &dev->input_pad[i]); in em28xx_v4l2_create_entities()
1013 dev_err(&dev->intf->dev, in em28xx_v4l2_create_entities()
1016 ret = media_device_register_entity(dev->media_dev, ent); in em28xx_v4l2_create_entities()
1018 dev_err(&dev->intf->dev, in em28xx_v4l2_create_entities()
1032 struct em28xx *dev = vb2_get_drv_priv(vq); in queue_setup() local
1033 struct em28xx_v4l2 *v4l2 = dev->v4l2; in queue_setup()
1042 em28xx_enable_analog_tuner(dev); in queue_setup()
1051 struct em28xx *dev = vb2_get_drv_priv(vb->vb2_queue); in buffer_prepare() local
1052 struct em28xx_v4l2 *v4l2 = dev->v4l2; in buffer_prepare()
1071 struct em28xx *dev = vb2_get_drv_priv(vq); in em28xx_start_analog_streaming() local
1072 struct em28xx_v4l2 *v4l2 = dev->v4l2; in em28xx_start_analog_streaming()
1079 dev->v4l2->field_count = 0; in em28xx_start_analog_streaming()
1085 rc = res_get(dev, vq->type); in em28xx_start_analog_streaming()
1093 em28xx_set_alternate(dev); in em28xx_start_analog_streaming()
1099 em28xx_wake_i2c(dev); in em28xx_start_analog_streaming()
1102 rc = em28xx_init_usb_xfer(dev, EM28XX_ANALOG_MODE, in em28xx_start_analog_streaming()
1103 dev->analog_xfer_bulk, in em28xx_start_analog_streaming()
1105 dev->max_pkt_size, in em28xx_start_analog_streaming()
1106 dev->packet_multiplier, in em28xx_start_analog_streaming()
1139 struct em28xx *dev = vb2_get_drv_priv(vq); in em28xx_stop_streaming() local
1140 struct em28xx_v4l2 *v4l2 = dev->v4l2; in em28xx_stop_streaming()
1141 struct em28xx_dmaqueue *vidq = &dev->vidq; in em28xx_stop_streaming()
1146 res_free(dev, vq->type); in em28xx_stop_streaming()
1153 em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE); in em28xx_stop_streaming()
1156 spin_lock_irqsave(&dev->slock, flags); in em28xx_stop_streaming()
1157 if (dev->usb_ctl.vid_buf) { in em28xx_stop_streaming()
1158 vb2_buffer_done(&dev->usb_ctl.vid_buf->vb.vb2_buf, in em28xx_stop_streaming()
1160 dev->usb_ctl.vid_buf = NULL; in em28xx_stop_streaming()
1169 spin_unlock_irqrestore(&dev->slock, flags); in em28xx_stop_streaming()
1174 struct em28xx *dev = vb2_get_drv_priv(vq); in em28xx_stop_vbi_streaming() local
1175 struct em28xx_v4l2 *v4l2 = dev->v4l2; in em28xx_stop_vbi_streaming()
1176 struct em28xx_dmaqueue *vbiq = &dev->vbiq; in em28xx_stop_vbi_streaming()
1181 res_free(dev, vq->type); in em28xx_stop_vbi_streaming()
1188 em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE); in em28xx_stop_vbi_streaming()
1191 spin_lock_irqsave(&dev->slock, flags); in em28xx_stop_vbi_streaming()
1192 if (dev->usb_ctl.vbi_buf) { in em28xx_stop_vbi_streaming()
1193 vb2_buffer_done(&dev->usb_ctl.vbi_buf->vb.vb2_buf, in em28xx_stop_vbi_streaming()
1195 dev->usb_ctl.vbi_buf = NULL; in em28xx_stop_vbi_streaming()
1204 spin_unlock_irqrestore(&dev->slock, flags); in em28xx_stop_vbi_streaming()
1211 struct em28xx *dev = vb2_get_drv_priv(vb->vb2_queue); in buffer_queue() local
1214 struct em28xx_dmaqueue *vidq = &dev->vidq; in buffer_queue()
1221 spin_lock_irqsave(&dev->slock, flags); in buffer_queue()
1223 spin_unlock_irqrestore(&dev->slock, flags); in buffer_queue()
1236 static int em28xx_vb2_setup(struct em28xx *dev) in em28xx_vb2_setup() argument
1240 struct em28xx_v4l2 *v4l2 = dev->v4l2; in em28xx_vb2_setup()
1247 q->drv_priv = dev; in em28xx_vb2_setup()
1261 q->drv_priv = dev; in em28xx_vb2_setup()
1277 static void video_mux(struct em28xx *dev, int index) in video_mux() argument
1279 struct v4l2_device *v4l2_dev = &dev->v4l2->v4l2_dev; in video_mux()
1281 dev->ctl_input = index; in video_mux()
1282 dev->ctl_ainput = INPUT(index)->amux; in video_mux()
1283 dev->ctl_aoutput = INPUT(index)->aout; in video_mux()
1285 if (!dev->ctl_aoutput) in video_mux()
1286 dev->ctl_aoutput = EM28XX_AOUT_MASTER; in video_mux()
1291 if (dev->has_msp34xx) { in video_mux()
1292 if (dev->i2s_speed) { in video_mux()
1294 s_i2s_clock_freq, dev->i2s_speed); in video_mux()
1298 dev->ctl_ainput, in video_mux()
1302 if (dev->board.adecoder != EM28XX_NOADECODER) { in video_mux()
1304 dev->ctl_ainput, dev->ctl_aoutput, 0); in video_mux()
1307 em28xx_audio_analog_set(dev); in video_mux()
1312 struct em28xx *dev = priv; in em28xx_ctrl_notify() local
1322 dev->mute = ctrl->val; in em28xx_ctrl_notify()
1323 em28xx_audio_analog_set(dev); in em28xx_ctrl_notify()
1326 dev->volume = ctrl->val; in em28xx_ctrl_notify()
1327 em28xx_audio_analog_set(dev); in em28xx_ctrl_notify()
1336 struct em28xx *dev = v4l2->dev; in em28xx_s_ctrl() local
1341 dev->mute = ctrl->val; in em28xx_s_ctrl()
1342 ret = em28xx_audio_analog_set(dev); in em28xx_s_ctrl()
1345 dev->volume = ctrl->val; in em28xx_s_ctrl()
1346 ret = em28xx_audio_analog_set(dev); in em28xx_s_ctrl()
1349 ret = em28xx_write_reg(dev, EM28XX_R20_YGAIN, ctrl->val); in em28xx_s_ctrl()
1352 ret = em28xx_write_reg(dev, EM28XX_R21_YOFFSET, ctrl->val); in em28xx_s_ctrl()
1355 ret = em28xx_write_reg(dev, EM28XX_R22_UVGAIN, ctrl->val); in em28xx_s_ctrl()
1358 ret = em28xx_write_reg(dev, EM28XX_R23_UOFFSET, ctrl->val); in em28xx_s_ctrl()
1361 ret = em28xx_write_reg(dev, EM28XX_R24_VOFFSET, ctrl->val); in em28xx_s_ctrl()
1364 ret = em28xx_write_reg(dev, EM28XX_R25_SHARPNESS, ctrl->val); in em28xx_s_ctrl()
1375 static void size_to_scale(struct em28xx *dev, in size_to_scale() argument
1379 unsigned int maxw = norm_maxw(dev); in size_to_scale()
1380 unsigned int maxh = norm_maxh(dev); in size_to_scale()
1391 static void scale_to_size(struct em28xx *dev, in scale_to_size() argument
1395 unsigned int maxw = norm_maxw(dev); in scale_to_size()
1396 unsigned int maxh = norm_maxh(dev); in scale_to_size()
1415 struct em28xx *dev = video_drvdata(file); in vidioc_g_fmt_vid_cap() local
1416 struct em28xx_v4l2 *v4l2 = dev->v4l2; in vidioc_g_fmt_vid_cap()
1448 struct em28xx *dev = video_drvdata(file); in vidioc_try_fmt_vid_cap() local
1449 struct em28xx_v4l2 *v4l2 = dev->v4l2; in vidioc_try_fmt_vid_cap()
1452 unsigned int maxw = norm_maxw(dev); in vidioc_try_fmt_vid_cap()
1453 unsigned int maxh = norm_maxh(dev); in vidioc_try_fmt_vid_cap()
1464 if (dev->board.is_em2800) { in vidioc_try_fmt_vid_cap()
1489 size_to_scale(dev, width, height, &hscale, &vscale); in vidioc_try_fmt_vid_cap()
1490 scale_to_size(dev, hscale, vscale, &width, &height); in vidioc_try_fmt_vid_cap()
1507 static int em28xx_set_video_format(struct em28xx *dev, unsigned int fourcc, in em28xx_set_video_format() argument
1511 struct em28xx_v4l2 *v4l2 = dev->v4l2; in em28xx_set_video_format()
1522 size_to_scale(dev, v4l2->width, v4l2->height, in em28xx_set_video_format()
1525 em28xx_resolution_set(dev); in em28xx_set_video_format()
1533 struct em28xx *dev = video_drvdata(file); in vidioc_s_fmt_vid_cap() local
1534 struct em28xx_v4l2 *v4l2 = dev->v4l2; in vidioc_s_fmt_vid_cap()
1541 return em28xx_set_video_format(dev, f->fmt.pix.pixelformat, in vidioc_s_fmt_vid_cap()
1547 struct em28xx *dev = video_drvdata(file); in vidioc_g_std() local
1549 *norm = dev->v4l2->norm; in vidioc_g_std()
1556 struct em28xx *dev = video_drvdata(file); in vidioc_querystd() local
1558 v4l2_device_call_all(&dev->v4l2->v4l2_dev, 0, video, querystd, norm); in vidioc_querystd()
1565 struct em28xx *dev = video_drvdata(file); in vidioc_s_std() local
1566 struct em28xx_v4l2 *v4l2 = dev->v4l2; in vidioc_s_std()
1585 size_to_scale(dev, v4l2->width, v4l2->height, in vidioc_s_std()
1588 em28xx_resolution_set(dev); in vidioc_s_std()
1598 struct em28xx *dev = video_drvdata(file); in vidioc_g_parm() local
1599 struct em28xx_v4l2 *v4l2 = dev->v4l2; in vidioc_g_parm()
1608 if (dev->is_webcam) { in vidioc_g_parm()
1624 struct em28xx *dev = video_drvdata(file); in vidioc_s_parm() local
1631 if (!dev->is_webcam) in vidioc_s_parm()
1641 rc = v4l2_device_call_until_err(&dev->v4l2->v4l2_dev, 0, in vidioc_s_parm()
1651 struct em28xx *dev = video_drvdata(file); in vidioc_enum_input() local
1668 i->std = dev->v4l2->vdev.tvnorms; in vidioc_enum_input()
1670 if (dev->is_webcam) in vidioc_enum_input()
1676 if (dev->amux_map[j] != EM28XX_AMUX_UNUSED) in vidioc_enum_input()
1684 struct em28xx *dev = video_drvdata(file); in vidioc_g_input() local
1686 *i = dev->ctl_input; in vidioc_g_input()
1693 struct em28xx *dev = video_drvdata(file); in vidioc_s_input() local
1700 video_mux(dev, i); in vidioc_s_input()
1704 static int em28xx_fill_audio_input(struct em28xx *dev, in em28xx_fill_audio_input() argument
1709 unsigned int idx = dev->amux_map[index]; in em28xx_fill_audio_input()
1718 if (dev->has_msp34xx && idx != EM28XX_AMUX_UNUSED) in em28xx_fill_audio_input()
1761 struct em28xx *dev = video_drvdata(file); in vidioc_enumaudio() local
1766 return em28xx_fill_audio_input(dev, __func__, a, a->index); in vidioc_enumaudio()
1771 struct em28xx *dev = video_drvdata(file); in vidioc_g_audio() local
1775 if (dev->ctl_ainput == dev->amux_map[i]) in vidioc_g_audio()
1776 return em28xx_fill_audio_input(dev, __func__, a, i); in vidioc_g_audio()
1785 struct em28xx *dev = video_drvdata(file); in vidioc_s_audio() local
1791 idx = dev->amux_map[a->index]; in vidioc_s_audio()
1796 dev->ctl_ainput = idx; in vidioc_s_audio()
1806 if (idx == dev->amux_map[i]) in vidioc_s_audio()
1811 dev->ctl_aoutput = INPUT(i)->aout; in vidioc_s_audio()
1813 if (!dev->ctl_aoutput) in vidioc_s_audio()
1814 dev->ctl_aoutput = EM28XX_AOUT_MASTER; in vidioc_s_audio()
1817 dev->ctl_ainput); in vidioc_s_audio()
1825 struct em28xx *dev = video_drvdata(file); in vidioc_g_tuner() local
1832 v4l2_device_call_all(&dev->v4l2->v4l2_dev, 0, tuner, g_tuner, t); in vidioc_g_tuner()
1839 struct em28xx *dev = video_drvdata(file); in vidioc_s_tuner() local
1844 v4l2_device_call_all(&dev->v4l2->v4l2_dev, 0, tuner, s_tuner, t); in vidioc_s_tuner()
1851 struct em28xx *dev = video_drvdata(file); in vidioc_g_frequency() local
1852 struct em28xx_v4l2 *v4l2 = dev->v4l2; in vidioc_g_frequency()
1865 struct em28xx *dev = video_drvdata(file); in vidioc_s_frequency() local
1866 struct em28xx_v4l2 *v4l2 = dev->v4l2; in vidioc_s_frequency()
1882 struct em28xx *dev = video_drvdata(file); in vidioc_g_chip_info() local
1890 dev->v4l2->v4l2_dev.name, sizeof(chip->name)); in vidioc_g_chip_info()
1909 struct em28xx *dev = video_drvdata(file); in vidioc_g_register() local
1915 ret = em28xx_read_ac97(dev, reg->reg); in vidioc_g_register()
1927 ret = em28xx_read_reg(dev, reg->reg); in vidioc_g_register()
1936 ret = dev->em28xx_read_reg_req_len(dev, USB_REQ_GET_STATUS, in vidioc_g_register()
1950 struct em28xx *dev = video_drvdata(file); in vidioc_s_register() local
1956 return em28xx_write_ac97(dev, reg->reg, reg->val); in vidioc_s_register()
1961 return em28xx_write_regs(dev, reg->reg, (char *)&buf, in vidioc_s_register()
1969 struct em28xx *dev = video_drvdata(file); in vidioc_querycap() local
1970 struct em28xx_v4l2 *v4l2 = dev->v4l2; in vidioc_querycap()
1971 struct usb_device *udev = interface_to_usbdev(dev->intf); in vidioc_querycap()
1974 strscpy(cap->card, em28xx_boards[dev->model].name, sizeof(cap->card)); in vidioc_querycap()
1979 if (dev->int_audio_type != EM28XX_INT_AUDIO_NONE) in vidioc_querycap()
1981 if (dev->tuner_type != TUNER_ABSENT) in vidioc_querycap()
2004 struct em28xx *dev = video_drvdata(file); in vidioc_enum_framesizes() local
2006 unsigned int maxw = norm_maxw(dev); in vidioc_enum_framesizes()
2007 unsigned int maxh = norm_maxh(dev); in vidioc_enum_framesizes()
2016 if (dev->board.is_em2800) { in vidioc_enum_framesizes()
2030 scale_to_size(dev, EM28XX_HVSCALE_MAX, EM28XX_HVSCALE_MAX, in vidioc_enum_framesizes()
2048 struct em28xx *dev = video_drvdata(file); in vidioc_g_fmt_vbi_cap() local
2049 struct em28xx_v4l2 *v4l2 = dev->v4l2; in vidioc_g_fmt_vbi_cap()
2081 struct em28xx *dev = video_drvdata(file); in radio_g_tuner() local
2088 v4l2_device_call_all(&dev->v4l2->v4l2_dev, 0, tuner, g_tuner, t); in radio_g_tuner()
2096 struct em28xx *dev = video_drvdata(file); in radio_s_tuner() local
2101 v4l2_device_call_all(&dev->v4l2->v4l2_dev, 0, tuner, s_tuner, t); in radio_s_tuner()
2117 v4l2->dev->v4l2 = NULL; in em28xx_free_v4l2()
2128 struct em28xx *dev = video_drvdata(filp); in em28xx_v4l2_open() local
2129 struct em28xx_v4l2 *v4l2 = dev->v4l2; in em28xx_v4l2_open()
2150 if (mutex_lock_interruptible(&dev->lock)) in em28xx_v4l2_open()
2155 dev_err(&dev->intf->dev, in em28xx_v4l2_open()
2158 mutex_unlock(&dev->lock); in em28xx_v4l2_open()
2163 em28xx_set_mode(dev, EM28XX_ANALOG_MODE); in em28xx_v4l2_open()
2166 em28xx_resolution_set(dev); in em28xx_v4l2_open()
2172 em28xx_wake_i2c(dev); in em28xx_v4l2_open()
2180 kref_get(&dev->ref); in em28xx_v4l2_open()
2184 mutex_unlock(&dev->lock); in em28xx_v4l2_open()
2194 static int em28xx_v4l2_fini(struct em28xx *dev) in em28xx_v4l2_fini() argument
2196 struct em28xx_v4l2 *v4l2 = dev->v4l2; in em28xx_v4l2_fini()
2198 if (dev->is_audio_only) { in em28xx_v4l2_fini()
2203 if (!dev->has_video) { in em28xx_v4l2_fini()
2211 dev_info(&dev->intf->dev, "Closing video extension\n"); in em28xx_v4l2_fini()
2213 mutex_lock(&dev->lock); in em28xx_v4l2_fini()
2217 em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE); in em28xx_v4l2_fini()
2219 em28xx_v4l2_media_release(dev); in em28xx_v4l2_fini()
2222 dev_info(&dev->intf->dev, "V4L2 device %s deregistered\n", in em28xx_v4l2_fini()
2227 dev_info(&dev->intf->dev, "V4L2 device %s deregistered\n", in em28xx_v4l2_fini()
2232 dev_info(&dev->intf->dev, "V4L2 device %s deregistered\n", in em28xx_v4l2_fini()
2242 mutex_unlock(&dev->lock); in em28xx_v4l2_fini()
2244 kref_put(&dev->ref, em28xx_free_device); in em28xx_v4l2_fini()
2249 static int em28xx_v4l2_suspend(struct em28xx *dev) in em28xx_v4l2_suspend() argument
2251 if (dev->is_audio_only) in em28xx_v4l2_suspend()
2254 if (!dev->has_video) in em28xx_v4l2_suspend()
2257 dev_info(&dev->intf->dev, "Suspending video extension\n"); in em28xx_v4l2_suspend()
2258 em28xx_stop_urbs(dev); in em28xx_v4l2_suspend()
2262 static int em28xx_v4l2_resume(struct em28xx *dev) in em28xx_v4l2_resume() argument
2264 if (dev->is_audio_only) in em28xx_v4l2_resume()
2267 if (!dev->has_video) in em28xx_v4l2_resume()
2270 dev_info(&dev->intf->dev, "Resuming video extension\n"); in em28xx_v4l2_resume()
2282 struct em28xx *dev = video_drvdata(filp); in em28xx_v4l2_close() local
2283 struct em28xx_v4l2 *v4l2 = dev->v4l2; in em28xx_v4l2_close()
2284 struct usb_device *udev = interface_to_usbdev(dev->intf); in em28xx_v4l2_close()
2290 mutex_lock(&dev->lock); in em28xx_v4l2_close()
2294 if (dev->disconnected) in em28xx_v4l2_close()
2301 em28xx_set_mode(dev, EM28XX_SUSPEND); in em28xx_v4l2_close()
2304 dev->alt = 0; in em28xx_v4l2_close()
2308 dev_err(&dev->intf->dev, in em28xx_v4l2_close()
2317 mutex_unlock(&dev->lock); in em28xx_v4l2_close()
2318 kref_put(&dev->ref, em28xx_free_device); in em28xx_v4l2_close()
2432 static void em28xx_vdev_init(struct em28xx *dev, in em28xx_vdev_init() argument
2438 vfd->v4l2_dev = &dev->v4l2->v4l2_dev; in em28xx_vdev_init()
2439 vfd->lock = &dev->lock; in em28xx_vdev_init()
2440 if (dev->is_webcam) in em28xx_vdev_init()
2444 dev_name(&dev->intf->dev), type_name); in em28xx_vdev_init()
2446 video_set_drvdata(vfd, dev); in em28xx_vdev_init()
2449 static void em28xx_tuner_setup(struct em28xx *dev, unsigned short tuner_addr) in em28xx_tuner_setup() argument
2451 struct em28xx_v4l2 *v4l2 = dev->v4l2; in em28xx_tuner_setup()
2461 if (dev->board.radio.type) { in em28xx_tuner_setup()
2462 tun_setup.type = dev->board.radio.type; in em28xx_tuner_setup()
2463 tun_setup.addr = dev->board.radio_addr; in em28xx_tuner_setup()
2469 if (dev->tuner_type != TUNER_ABSENT && dev->tuner_type) { in em28xx_tuner_setup()
2470 tun_setup.type = dev->tuner_type; in em28xx_tuner_setup()
2477 if (dev->board.tda9887_conf) { in em28xx_tuner_setup()
2481 tda9887_cfg.priv = &dev->board.tda9887_conf; in em28xx_tuner_setup()
2487 if (dev->tuner_type == TUNER_XC2028) { in em28xx_tuner_setup()
2494 em28xx_setup_xc3028(dev, &ctl); in em28xx_tuner_setup()
2510 static int em28xx_v4l2_init(struct em28xx *dev) in em28xx_v4l2_init() argument
2518 if (dev->is_audio_only) { in em28xx_v4l2_init()
2523 if (!dev->has_video) { in em28xx_v4l2_init()
2528 dev_info(&dev->intf->dev, "Registering V4L2 extension\n"); in em28xx_v4l2_init()
2530 mutex_lock(&dev->lock); in em28xx_v4l2_init()
2534 mutex_unlock(&dev->lock); in em28xx_v4l2_init()
2538 v4l2->dev = dev; in em28xx_v4l2_init()
2539 dev->v4l2 = v4l2; in em28xx_v4l2_init()
2542 v4l2->v4l2_dev.mdev = dev->media_dev; in em28xx_v4l2_init()
2544 ret = v4l2_device_register(&dev->intf->dev, &v4l2->v4l2_dev); in em28xx_v4l2_init()
2546 dev_err(&dev->intf->dev, in em28xx_v4l2_init()
2555 if (dev->is_webcam) in em28xx_v4l2_init()
2567 if (dev->has_msp34xx) in em28xx_v4l2_init()
2569 &dev->i2c_adap[dev->def_i2c_bus], in em28xx_v4l2_init()
2572 if (dev->board.decoder == EM28XX_SAA711X) in em28xx_v4l2_init()
2574 &dev->i2c_adap[dev->def_i2c_bus], in em28xx_v4l2_init()
2577 if (dev->board.decoder == EM28XX_TVP5150) in em28xx_v4l2_init()
2579 &dev->i2c_adap[dev->def_i2c_bus], in em28xx_v4l2_init()
2582 if (dev->board.adecoder == EM28XX_TVAUDIO) in em28xx_v4l2_init()
2584 &dev->i2c_adap[dev->def_i2c_bus], in em28xx_v4l2_init()
2585 "tvaudio", dev->board.tvaudio_addr, NULL); in em28xx_v4l2_init()
2589 if (dev->board.tuner_type != TUNER_ABSENT) { in em28xx_v4l2_init()
2590 unsigned short tuner_addr = dev->board.tuner_addr; in em28xx_v4l2_init()
2591 int has_demod = (dev->board.tda9887_conf & TDA9887_PRESENT); in em28xx_v4l2_init()
2593 if (dev->board.radio.type) in em28xx_v4l2_init()
2595 &dev->i2c_adap[dev->def_i2c_bus], in em28xx_v4l2_init()
2596 "tuner", dev->board.radio_addr, in em28xx_v4l2_init()
2601 &dev->i2c_adap[dev->def_i2c_bus], in em28xx_v4l2_init()
2610 &dev->i2c_adap[dev->def_i2c_bus], in em28xx_v4l2_init()
2618 &dev->i2c_adap[dev->def_i2c_bus], in em28xx_v4l2_init()
2622 em28xx_tuner_setup(dev, tuner_addr); in em28xx_v4l2_init()
2625 if (dev->em28xx_sensor != EM28XX_NOSENSOR) in em28xx_v4l2_init()
2626 em28xx_init_camera(dev); in em28xx_v4l2_init()
2629 ret = em28xx_audio_setup(dev); in em28xx_v4l2_init()
2631 dev_err(&dev->intf->dev, in em28xx_v4l2_init()
2636 if (dev->audio_mode.ac97 != EM28XX_NO_AC97) { in em28xx_v4l2_init()
2644 em28xx_ctrl_notify, dev); in em28xx_v4l2_init()
2646 em28xx_ctrl_notify, dev); in em28xx_v4l2_init()
2650 em28xx_wake_i2c(dev); in em28xx_v4l2_init()
2653 INIT_LIST_HEAD(&dev->vidq.active); in em28xx_v4l2_init()
2654 INIT_LIST_HEAD(&dev->vbiq.active); in em28xx_v4l2_init()
2656 if (dev->has_msp34xx) { in em28xx_v4l2_init()
2658 ret = em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xf7); in em28xx_v4l2_init()
2660 dev_err(&dev->intf->dev, in em28xx_v4l2_init()
2667 ret = em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xff); in em28xx_v4l2_init()
2669 dev_err(&dev->intf->dev, in em28xx_v4l2_init()
2685 maxw = norm_maxw(dev); in em28xx_v4l2_init()
2690 if (dev->board.is_em2800) in em28xx_v4l2_init()
2693 em28xx_set_video_format(dev, format[0].fourcc, in em28xx_v4l2_init()
2694 maxw, norm_maxh(dev)); in em28xx_v4l2_init()
2696 video_mux(dev, 0); in em28xx_v4l2_init()
2699 dev->mute = 1; in em28xx_v4l2_init()
2700 dev->volume = 0x1f; in em28xx_v4l2_init()
2703 val = (u8)em28xx_read_reg(dev, EM28XX_R0F_XCLK); in em28xx_v4l2_init()
2704 em28xx_write_reg(dev, EM28XX_R0F_XCLK, in em28xx_v4l2_init()
2707 em28xx_set_outfmt(dev); in em28xx_v4l2_init()
2742 em28xx_colorlevels_set_default(dev); in em28xx_v4l2_init()
2749 em28xx_vdev_init(dev, &v4l2->vdev, &em28xx_video_template, "video"); in em28xx_v4l2_init()
2756 if (dev->int_audio_type != EM28XX_INT_AUDIO_NONE) in em28xx_v4l2_init()
2758 if (dev->tuner_type != TUNER_ABSENT) in em28xx_v4l2_init()
2763 if (dev->is_webcam) { in em28xx_v4l2_init()
2770 if (dev->tuner_type == TUNER_ABSENT) { in em28xx_v4l2_init()
2776 if (dev->int_audio_type == EM28XX_INT_AUDIO_NONE) { in em28xx_v4l2_init()
2783 video_nr[dev->devno]); in em28xx_v4l2_init()
2785 dev_err(&dev->intf->dev, in em28xx_v4l2_init()
2791 if (em28xx_vbi_supported(dev) == 1) { in em28xx_v4l2_init()
2792 em28xx_vdev_init(dev, &v4l2->vbi_dev, &em28xx_video_template, in em28xx_v4l2_init()
2799 if (dev->tuner_type != TUNER_ABSENT) in em28xx_v4l2_init()
2804 if (dev->tuner_type == TUNER_ABSENT) { in em28xx_v4l2_init()
2810 if (dev->int_audio_type == EM28XX_INT_AUDIO_NONE) { in em28xx_v4l2_init()
2817 vbi_nr[dev->devno]); in em28xx_v4l2_init()
2819 dev_err(&dev->intf->dev, in em28xx_v4l2_init()
2825 if (em28xx_boards[dev->model].radio.type == EM28XX_RADIO) { in em28xx_v4l2_init()
2826 em28xx_vdev_init(dev, &v4l2->radio_dev, &em28xx_radio_template, in em28xx_v4l2_init()
2830 radio_nr[dev->devno]); in em28xx_v4l2_init()
2832 dev_err(&dev->intf->dev, in em28xx_v4l2_init()
2836 dev_info(&dev->intf->dev, in em28xx_v4l2_init()
2842 em28xx_v4l2_create_entities(dev); in em28xx_v4l2_init()
2845 ret = v4l2_mc_create_media_graph(dev->media_dev); in em28xx_v4l2_init()
2847 dev_err(&dev->intf->dev, in em28xx_v4l2_init()
2849 em28xx_v4l2_media_release(dev); in em28xx_v4l2_init()
2854 dev_info(&dev->intf->dev, in em28xx_v4l2_init()
2859 dev_info(&dev->intf->dev, in em28xx_v4l2_init()
2867 em28xx_vb2_setup(dev); in em28xx_v4l2_init()
2869 dev_info(&dev->intf->dev, in em28xx_v4l2_init()
2872 kref_get(&dev->ref); in em28xx_v4l2_init()
2874 mutex_unlock(&dev->lock); in em28xx_v4l2_init()
2879 dev_info(&dev->intf->dev, in em28xx_v4l2_init()
2885 dev_info(&dev->intf->dev, in em28xx_v4l2_init()
2891 dev_info(&dev->intf->dev, in em28xx_v4l2_init()
2900 dev->v4l2 = NULL; in em28xx_v4l2_init()
2902 mutex_unlock(&dev->lock); in em28xx_v4l2_init()