From patchwork Fri Apr 3 21:45:17 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Klimov X-Patchwork-Id: 666 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Fri, 03 Apr 2009 21:45:25 +0000 Received: from vger.kernel.org ([209.132.176.167]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1LprCX-00008Y-1W; Fri, 03 Apr 2009 21:45:25 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759328AbZDCVpY (ORCPT + 1 other); Fri, 3 Apr 2009 17:45:24 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1760793AbZDCVpY (ORCPT ); Fri, 3 Apr 2009 17:45:24 -0400 Received: from mail-fx0-f158.google.com ([209.85.220.158]:46633 "EHLO mail-fx0-f158.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759328AbZDCVpX (ORCPT ); Fri, 3 Apr 2009 17:45:23 -0400 Received: by fxm2 with SMTP id 2so1154392fxm.37 for ; Fri, 03 Apr 2009 14:45:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:cc :content-type:date:message-id:mime-version:x-mailer :content-transfer-encoding; bh=cQOEKuMrlXHacoeNpd9Nd4V+mYx8+WDZiig4ieIKS04=; b=FkP1coOjsyRszfSOpWQcv2nuV9umTrTDoBKMy9L/om7wzCEXsp5K5DDdoqqj1t5cOF F0xemQEA4xT4jnYsFsC6Y5NwO1d0dVobx8dXP7Al+BIxLrTkrJkeMB4m4uZgBj49RQeu S2qSuGjo3H6B5RNuv1ZzrwWpckcHpi5BkY+78= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; b=AbkgsmO/vhfvqjQnATo3tdlzl/YSows+hx6USAYPkRFOu/qCM+t3ogb9kjkbABHJdU k8hEZIz7MlHxGJiLnwR4sBSivqlQ1UrCBXUgXXj0taSnQv3ur0i7swfn5ObWKrghsJam pE+91B1DO5m6F+BPnHAPwt8jC6BBUwAftP5Tg= Received: by 10.102.228.10 with SMTP id a10mr807136muh.26.1238795120417; Fri, 03 Apr 2009 14:45:20 -0700 (PDT) Received: from ?192.168.1.42? (gw.zunet.ru [217.67.117.64]) by mx.google.com with ESMTPS id j9sm4363038mue.10.2009.04.03.14.45.19 (version=SSLv3 cipher=RC4-MD5); Fri, 03 Apr 2009 14:45:19 -0700 (PDT) Subject: [patch 1/2] dsbr100 radio: convert to to v4l2_device From: Alexey Klimov To: Douglas Schilling Landgraf Cc: linux-media@vger.kernel.org, klimov.linux@gmail.com Date: Sat, 04 Apr 2009 01:45:17 +0400 Message-Id: <1238795117.3102.13.camel@tux.localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.24.5 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org dsbr100: convert to v4l2_device. Signed-off-by: Alexey Klimov diff -r f86c84534cb4 linux/drivers/media/radio/dsbr100.c --- a/linux/drivers/media/radio/dsbr100.c Sun Mar 29 22:54:35 2009 -0300 +++ b/linux/drivers/media/radio/dsbr100.c Tue Mar 31 15:54:36 2009 +0400 @@ -32,6 +32,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA History: + + Version 0.45: + Converted to v4l2_device. Version 0.44: Add suspend/resume functions, fix unplug of device, @@ -88,7 +91,7 @@ #include #include #include -#include +#include #include #include #include "compat.h" @@ -98,39 +101,8 @@ */ #include /* for KERNEL_VERSION MACRO */ -#define DRIVER_VERSION "v0.44" -#define RADIO_VERSION KERNEL_VERSION(0, 4, 4) - -static struct v4l2_queryctrl radio_qctrl[] = { - { - .id = V4L2_CID_AUDIO_MUTE, - .name = "Mute", - .minimum = 0, - .maximum = 1, - .default_value = 1, - .type = V4L2_CTRL_TYPE_BOOLEAN, - }, -/* HINT: the disabled controls are only here to satify kradio and such apps */ - { .id = V4L2_CID_AUDIO_VOLUME, - .flags = V4L2_CTRL_FLAG_DISABLED, - }, - { - .id = V4L2_CID_AUDIO_BALANCE, - .flags = V4L2_CTRL_FLAG_DISABLED, - }, - { - .id = V4L2_CID_AUDIO_BASS, - .flags = V4L2_CTRL_FLAG_DISABLED, - }, - { - .id = V4L2_CID_AUDIO_TREBLE, - .flags = V4L2_CTRL_FLAG_DISABLED, - }, - { - .id = V4L2_CID_AUDIO_LOUDNESS, - .flags = V4L2_CTRL_FLAG_DISABLED, - }, -}; +#define DRIVER_VERSION "v0.45" +#define RADIO_VERSION KERNEL_VERSION(0, 4, 5) #define DRIVER_AUTHOR "Markus Demleitner " #define DRIVER_DESC "D-Link DSB-R100 USB FM radio driver" @@ -168,6 +140,8 @@ struct dsbr100_device { struct usb_device *usbdev; struct video_device videodev; + struct v4l2_device v4l2_dev; + u8 *transfer_buffer; struct mutex lock; /* buffer locking */ int curfreq; @@ -387,6 +361,7 @@ mutex_unlock(&radio->lock); video_unregister_device(&radio->videodev); + v4l2_device_disconnect(&radio->v4l2_dev); } @@ -482,14 +457,11 @@ static int vidioc_queryctrl(struct file *file, void *priv, struct v4l2_queryctrl *qc) { - int i; + switch (qc->id) { + case V4L2_CID_AUDIO_MUTE: + return v4l2_ctrl_query_fill(qc, 0, 1, 1, 1); + } - for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { - if (qc->id && qc->id == radio_qctrl[i].id) { - memcpy(qc, &(radio_qctrl[i]), sizeof(*qc)); - return 0; - } - } return -EINVAL; } @@ -659,6 +631,7 @@ { struct dsbr100_device *radio = videodev_to_radio(videodev); + v4l2_device_unregister(&radio->v4l2_dev); kfree(radio->transfer_buffer); kfree(radio); } @@ -686,22 +659,15 @@ .vidioc_s_input = vidioc_s_input, }; -/* V4L2 interface */ -static struct video_device dsbr100_videodev_data = { - .name = "D-Link DSB-R 100", - .fops = &usb_dsbr100_fops, - .ioctl_ops = &usb_dsbr100_ioctl_ops, - .release = usb_dsbr100_video_device_release, -}; - /* check if the device is present and register with v4l and usb if it is */ static int usb_dsbr100_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct dsbr100_device *radio; + struct v4l2_device *v4l2_dev; int retval; - radio = kmalloc(sizeof(struct dsbr100_device), GFP_KERNEL); + radio = kzalloc(sizeof(struct dsbr100_device), GFP_KERNEL); if (!radio) return -ENOMEM; @@ -713,17 +679,35 @@ return -ENOMEM; } + v4l2_dev = &radio->v4l2_dev; + + retval = v4l2_device_register(&intf->dev, v4l2_dev); + if (retval < 0) { + v4l2_err(v4l2_dev, "couldn't register v4l2_device\n"); + kfree(radio->transfer_buffer); + kfree(radio); + return retval; + } + + strlcpy(radio->videodev.name, v4l2_dev->name, sizeof(radio->videodev.name)); + radio->videodev.v4l2_dev = v4l2_dev; + radio->videodev.fops = &usb_dsbr100_fops; + radio->videodev.ioctl_ops = &usb_dsbr100_ioctl_ops; + radio->videodev.release = usb_dsbr100_video_device_release; + mutex_init(&radio->lock); - radio->videodev = dsbr100_videodev_data; radio->removed = 0; radio->users = 0; radio->usbdev = interface_to_usbdev(intf); radio->curfreq = FREQ_MIN * FREQ_MUL; + video_set_drvdata(&radio->videodev, radio); + retval = video_register_device(&radio->videodev, VFL_TYPE_RADIO, radio_nr); if (retval < 0) { - dev_err(&intf->dev, "couldn't register video device\n"); + v4l2_err(v4l2_dev, "couldn't register video device\n"); + v4l2_device_unregister(v4l2_dev); kfree(radio->transfer_buffer); kfree(radio); return -EIO;