--- zzzz-none-000/linux-3.10.107/drivers/media/usb/cx231xx/cx231xx-417.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/media/usb/cx231xx/cx231xx-417.c 2021-02-04 17:41:59.000000000 +0000 @@ -24,6 +24,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "cx231xx.h" + #include #include #include @@ -37,9 +39,6 @@ #include #include #include -#include - -#include "cx231xx.h" #define CX231xx_FIRM_IMAGE_SIZE 376836 #define CX231xx_FIRM_IMAGE_NAME "v4l-cx23885-enc.fw" @@ -90,10 +89,10 @@ module_param(v4l_debug, int, 0644); MODULE_PARM_DESC(v4l_debug, "enable V4L debug messages"); -#define dprintk(level, fmt, arg...)\ - do { if (v4l_debug >= level) \ - pr_info("%s: " fmt, \ - (dev) ? dev->name : "cx231xx[?]", ## arg); \ +#define dprintk(level, fmt, arg...) \ + do { \ + if (v4l_debug >= level) \ + printk(KERN_DEBUG pr_fmt(fmt), ## arg); \ } while (0) static struct cx231xx_tvnorm cx231xx_tvnorms[] = { @@ -988,29 +987,34 @@ IVTV_REG_APU, 0); if (retval != 0) { - pr_err("%s: Error with mc417_register_write\n", __func__); + dev_err(dev->dev, + "%s: Error with mc417_register_write\n", __func__); return -1; } retval = request_firmware(&firmware, CX231xx_FIRM_IMAGE_NAME, - &dev->udev->dev); + dev->dev); if (retval != 0) { - pr_err("ERROR: Hotplug firmware request failed (%s).\n", + dev_err(dev->dev, + "ERROR: Hotplug firmware request failed (%s).\n", CX231xx_FIRM_IMAGE_NAME); - pr_err("Please fix your hotplug setup, the board will not work without firmware loaded!\n"); + dev_err(dev->dev, + "Please fix your hotplug setup, the board will not work without firmware loaded!\n"); return -1; } if (firmware->size != CX231xx_FIRM_IMAGE_SIZE) { - pr_err("ERROR: Firmware size mismatch (have %zd, expected %d)\n", + dev_err(dev->dev, + "ERROR: Firmware size mismatch (have %zd, expected %d)\n", firmware->size, CX231xx_FIRM_IMAGE_SIZE); release_firmware(firmware); return -1; } if (0 != memcmp(firmware->data, magic, 8)) { - pr_err("ERROR: Firmware magic mismatch, wrong file?\n"); + dev_err(dev->dev, + "ERROR: Firmware magic mismatch, wrong file?\n"); release_firmware(firmware); return -1; } @@ -1057,7 +1061,8 @@ retval |= mc417_register_write(dev, IVTV_REG_HW_BLOCKS, IVTV_CMD_HW_BLOCKS_RST); if (retval < 0) { - pr_err("%s: Error with mc417_register_write\n", + dev_err(dev->dev, + "%s: Error with mc417_register_write\n", __func__); return retval; } @@ -1069,7 +1074,8 @@ retval |= mc417_register_write(dev, IVTV_REG_VPU, value & 0xFFFFFFE8); if (retval < 0) { - pr_err("%s: Error with mc417_register_write\n", + dev_err(dev->dev, + "%s: Error with mc417_register_write\n", __func__); return retval; } @@ -1114,28 +1120,31 @@ cx231xx_disable656(dev); retval = cx231xx_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); /* ping */ if (retval < 0) { - dprintk(2, "%s() PING OK\n", __func__); + dprintk(2, "%s: PING OK\n", __func__); retval = cx231xx_load_firmware(dev); if (retval < 0) { - pr_err("%s() f/w load failed\n", __func__); + dev_err(dev->dev, + "%s: f/w load failed\n", __func__); return retval; } retval = cx231xx_find_mailbox(dev); if (retval < 0) { - pr_err("%s() mailbox < 0, error\n", + dev_err(dev->dev, "%s: mailbox < 0, error\n", __func__); return -1; } dev->cx23417_mailbox = retval; retval = cx231xx_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); if (retval < 0) { - pr_err("ERROR: cx23417 firmware ping failed!\n"); + dev_err(dev->dev, + "ERROR: cx23417 firmware ping failed!\n"); return -1; } retval = cx231xx_api_cmd(dev, CX2341X_ENC_GET_VERSION, 0, 1, &version); if (retval < 0) { - pr_err("ERROR: cx23417 firmware get encoder: version failed!\n"); + dev_err(dev->dev, + "ERROR: cx23417 firmware get encoder: version failed!\n"); return -1; } dprintk(1, "cx23417 firmware version is 0x%08x\n", version); @@ -1151,9 +1160,9 @@ } cx231xx_enable656(dev); - /* stop mpeg capture */ - cx231xx_api_cmd(dev, CX2341X_ENC_STOP_CAPTURE, - 3, 0, 1, 3, 4); + + /* stop mpeg capture */ + cx231xx_api_cmd(dev, CX2341X_ENC_STOP_CAPTURE, 3, 0, 1, 3, 4); cx231xx_codec_settings(dev); msleep(60); @@ -1240,8 +1249,7 @@ struct cx231xx *dev = fh->dev; unsigned long flags = 0; - if (in_interrupt()) - BUG(); + BUG_ON(in_interrupt()); spin_lock_irqsave(&dev->video_mode.slock, flags); if (dev->USE_ISO) { @@ -1416,8 +1424,9 @@ if (!dev->video_mode.bulk_ctl.num_bufs) urb_init = 1; } - /*cx231xx_info("urb_init=%d dev->video_mode.max_pkt_size=%d\n", - urb_init, dev->video_mode.max_pkt_size);*/ + dev_dbg(dev->dev, + "urb_init=%d dev->video_mode.max_pkt_size=%d\n", + urb_init, dev->video_mode.max_pkt_size); dev->mode_tv = 1; if (urb_init) { @@ -1516,7 +1525,7 @@ dev->ts1.height = 576; cx2341x_handler_set_50hz(&dev->mpeg_ctrl_handler, true); } - call_all(dev, core, s_std, dev->norm); + call_all(dev, video, s_std, dev->norm); /* do mode control overrides */ cx231xx_do_mode_ctrl_overrides(dev); @@ -1563,7 +1572,6 @@ f->fmt.pix.width = dev->ts1.width; f->fmt.pix.height = dev->ts1.height; f->fmt.pix.field = V4L2_FIELD_INTERLACED; - f->fmt.pix.priv = 0; dprintk(1, "VIDIOC_G_FMT: w: %d, h: %d\n", dev->ts1.width, dev->ts1.height); dprintk(3, "exit vidioc_g_fmt_vid_cap()\n"); @@ -1582,7 +1590,6 @@ f->fmt.pix.sizeimage = mpeglines * mpeglinesize; f->fmt.pix.field = V4L2_FIELD_INTERLACED; f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; - f->fmt.pix.priv = 0; dprintk(1, "VIDIOC_TRY_FMT: w: %d, h: %d\n", dev->ts1.width, dev->ts1.height); dprintk(3, "exit vidioc_try_fmt_vid_cap()\n"); @@ -1690,7 +1697,7 @@ sizeof(struct cx231xx_buffer), fh, &dev->lock); /* videobuf_queue_sg_init(&fh->vidq, &cx231xx_qops, - &dev->udev->dev, &dev->ts1.slock, + dev->dev, &dev->ts1.slock, V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_INTERLACED, sizeof(struct cx231xx_buffer), @@ -1800,7 +1807,6 @@ static int mpeg_mmap(struct file *file, struct vm_area_struct *vma) { struct cx231xx_fh *fh = file->private_data; - struct cx231xx *dev = fh->dev; dprintk(2, "%s()\n", __func__); @@ -1840,7 +1846,6 @@ .vidioc_streamon = vidioc_streamon, .vidioc_streamoff = vidioc_streamoff, .vidioc_log_status = vidioc_log_status, - .vidioc_g_chip_ident = cx231xx_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .vidioc_g_register = cx231xx_g_register, .vidioc_s_register = cx231xx_s_register, @@ -1862,13 +1867,9 @@ dprintk(1, "%s()\n", __func__); dprintk(3, "%s()\n", __func__); - if (dev->v4l_device) { - if (-1 != dev->v4l_device->minor) - video_unregister_device(dev->v4l_device); - else - video_device_release(dev->v4l_device); + if (video_is_registered(&dev->v4l_device)) { + video_unregister_device(&dev->v4l_device); v4l2_ctrl_handler_free(&dev->mpeg_ctrl_handler.hdl); - dev->v4l_device = NULL; } } @@ -1876,13 +1877,15 @@ { struct cx231xx *dev = container_of(cxhdl, struct cx231xx, mpeg_ctrl_handler); int is_mpeg1 = val == V4L2_MPEG_VIDEO_ENCODING_MPEG_1; - struct v4l2_mbus_framefmt fmt; + struct v4l2_subdev_format format = { + .which = V4L2_SUBDEV_FORMAT_ACTIVE, + }; /* fix videodecoder resolution */ - fmt.width = cxhdl->width / (is_mpeg1 ? 2 : 1); - fmt.height = cxhdl->height; - fmt.code = V4L2_MBUS_FMT_FIXED; - v4l2_subdev_call(dev->sd_cx25840, video, s_mbus_fmt, &fmt); + format.format.width = cxhdl->width / (is_mpeg1 ? 2 : 1); + format.format.height = cxhdl->height; + format.format.code = MEDIA_BUS_FMT_FIXED; + v4l2_subdev_call(dev->sd_cx25840, pad, set_fmt, NULL, &format); return 0; } @@ -1905,26 +1908,21 @@ .s_video_encoding = cx231xx_s_video_encoding, }; -static struct video_device *cx231xx_video_dev_alloc( +static void cx231xx_video_dev_init( struct cx231xx *dev, struct usb_device *usbdev, - struct video_device *template, - char *type) + struct video_device *vfd, + const struct video_device *template, + const char *type) { - struct video_device *vfd; - dprintk(1, "%s()\n", __func__); - vfd = video_device_alloc(); - if (NULL == vfd) - return NULL; *vfd = *template; snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", dev->name, type, cx231xx_boards[dev->model].name); vfd->v4l2_dev = &dev->v4l2_dev; vfd->lock = &dev->lock; - vfd->release = video_device_release; - set_bit(V4L2_FL_USE_FH_PRIO, &vfd->flags); + vfd->release = video_device_release_empty; vfd->ctrl_handler = &dev->mpeg_ctrl_handler.hdl; video_set_drvdata(vfd, dev); if (dev->tuner_type == TUNER_ABSENT) { @@ -1933,9 +1931,6 @@ v4l2_disable_ioctl(vfd, VIDIOC_G_TUNER); v4l2_disable_ioctl(vfd, VIDIOC_S_TUNER); } - - return vfd; - } int cx231xx_417_register(struct cx231xx *dev) @@ -1978,9 +1973,9 @@ cx2341x_handler_set_50hz(&dev->mpeg_ctrl_handler, false); /* Allocate and initialize V4L video device */ - dev->v4l_device = cx231xx_video_dev_alloc(dev, - dev->udev, &cx231xx_mpeg_template, "mpeg"); - err = video_register_device(dev->v4l_device, + cx231xx_video_dev_init(dev, dev->udev, + &dev->v4l_device, &cx231xx_mpeg_template, "mpeg"); + err = video_register_device(&dev->v4l_device, VFL_TYPE_GRABBER, -1); if (err < 0) { dprintk(3, "%s: can't register mpeg device\n", dev->name); @@ -1989,7 +1984,7 @@ } dprintk(3, "%s: registered device video%d [mpeg]\n", - dev->name, dev->v4l_device->num); + dev->name, dev->v4l_device.num); return 0; }