From patchwork Thu Feb 12 11:37:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Rafael_Louren=C3=A7o_de_Lima_Chehab?= X-Patchwork-Id: 5818811 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B93019F30C for ; Thu, 12 Feb 2015 11:37:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D71052022A for ; Thu, 12 Feb 2015 11:37:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D7F5620165 for ; Thu, 12 Feb 2015 11:37:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755616AbbBLLh4 (ORCPT ); Thu, 12 Feb 2015 06:37:56 -0500 Received: from mail-qg0-f41.google.com ([209.85.192.41]:49875 "EHLO mail-qg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755201AbbBLLhz (ORCPT ); Thu, 12 Feb 2015 06:37:55 -0500 Received: by mail-qg0-f41.google.com with SMTP id i50so7402069qgf.0 for ; Thu, 12 Feb 2015 03:37:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; bh=KfnodKH4VD1EOsPu4DmAc50/ThhYyjbGCt9vg5CSTyU=; b=BFzRSMJYqPhwFEkWUEzxVzeelUPMB2ssRsOSJvQsIId34AXGwmRsogHXcUnwabTdcI Kdt1MhUDxkjpJ/P1f047jOlVVWinAIBR1DUX0qHk4RVeSdXHfgFlESVu9ev8rnDxiqOR Hsz/wG9gfx9Ux8dGPh4N3O5y/tqZiJaZQMjGUaJ1zdWNRHxFO8ZjHuBcm9EsWfgxrivb DX6oEmHQP/P7yEEMT16hB6lhi08v8tRlVlCYb+myghzCL5aIGriZ4DA5ppZs7crJKC+j LdlleU1qZ4iDxHV6zbv6DUC8X+hCAyCrnfvIwU3LEOY2GumsEN9AzW4t0DA4Kx8v9Rht vhww== X-Received: by 10.140.107.75 with SMTP id g69mr8647590qgf.103.1423741074613; Thu, 12 Feb 2015 03:37:54 -0800 (PST) Received: from rafael.lan ([186.222.155.130]) by mx.google.com with ESMTPSA id l3sm3733389qaf.36.2015.02.12.03.37.52 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Feb 2015 03:37:53 -0800 (PST) From: =?UTF-8?q?Rafael=20Louren=C3=A7o=20de=20Lima=20Chehab?= To: Linux Media Mailing List Cc: =?UTF-8?q?Rafael=20Louren=C3=A7o=20de=20Lima=20Chehab?= Subject: [PATCH v2] dvb-usb-v2: add support for the media controller at USB driver Date: Thu, 12 Feb 2015 09:37:25 -0200 Message-Id: <1423741045-4647-1-git-send-email-chehabrafael@gmail.com> X-Mailer: git-send-email 2.1.0 MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Create a struct media_device and add it to the dvb adapter. Please notice that the tuner is not mapped yet by the dvb core. Signed-off-by: Rafael Lourenço de Lima Chehab --- drivers/media/usb/dvb-usb-v2/dvb_usb.h | 5 +++ drivers/media/usb/dvb-usb-v2/dvb_usb_core.c | 61 +++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb.h b/drivers/media/usb/dvb-usb-v2/dvb_usb.h index 14e111e13e54..b273250d0e31 100644 --- a/drivers/media/usb/dvb-usb-v2/dvb_usb.h +++ b/drivers/media/usb/dvb-usb-v2/dvb_usb.h @@ -25,6 +25,7 @@ #include #include #include +#include #include "dvb_frontend.h" #include "dvb_demux.h" @@ -389,6 +390,10 @@ struct dvb_usb_device { struct delayed_work rc_query_work; void *priv; + +#if defined(CONFIG_MEDIA_CONTROLLER) + struct media_device *media_dev; +#endif }; extern int dvb_usbv2_probe(struct usb_interface *, diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c index 1950f37df835..16dca65e1d6b 100644 --- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c +++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c @@ -400,6 +400,55 @@ skip_feed_stop: return ret; } +static void dvb_usbv2_media_device_register(struct dvb_usb_device *d) +{ +#ifdef CONFIG_MEDIA_CONTROLLER + + struct media_device *mdev; + struct usb_device *udev = d->udev; + int ret; + + mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); + if (!mdev) + return; + + mdev->dev = &udev->dev; + strlcpy(mdev->model, d->name, sizeof(mdev->model)); + if (udev->serial) + strlcpy(mdev->serial, udev->serial, sizeof(mdev->serial)); + strcpy(mdev->bus_info, udev->devpath); + mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice); + mdev->driver_version = LINUX_VERSION_CODE; + + ret = media_device_register(mdev); + if (ret) { + dev_err(&d->udev->dev, + "Couldn't create a media device. Error: %d\n", + ret); + kfree(mdev); + return; + } + + d->media_dev = mdev; + + dev_info(&d->udev->dev, "media controller created\n"); + +#endif +} + +static void dvb_usbv2_media_device_unregister (struct dvb_usb_device *d) +{ +#ifdef CONFIG_MEDIA_CONTROLLER + if (!d->media_dev) + return; + + media_device_unregister(d->media_dev); + kfree(d->media_dev); + d->media_dev = NULL; + +#endif +} + static int dvb_usbv2_adapter_dvb_init(struct dvb_usb_adapter *adap) { int ret; @@ -416,6 +465,11 @@ static int dvb_usbv2_adapter_dvb_init(struct dvb_usb_adapter *adap) adap->dvb_adap.priv = adap; +#ifdef CONFIG_MEDIA_CONTROLLER + dvb_usbv2_media_device_register(d); + adap->dvb_adap.mdev = d->media_dev; +#endif + if (d->props->read_mac_address) { ret = d->props->read_mac_address(adap, adap->dvb_adap.proposed_mac); @@ -464,6 +518,7 @@ err_dvb_net_init: err_dvb_dmxdev_init: dvb_dmx_release(&adap->demux); err_dvb_dmx_init: + dvb_usbv2_media_device_unregister(d); dvb_unregister_adapter(&adap->dvb_adap); err_dvb_register_adapter: adap->dvb_adap.priv = NULL; @@ -472,6 +527,8 @@ err_dvb_register_adapter: static int dvb_usbv2_adapter_dvb_exit(struct dvb_usb_adapter *adap) { + struct dvb_usb_device *d = adap_to_d(adap); + dev_dbg(&adap_to_d(adap)->udev->dev, "%s: adap=%d\n", __func__, adap->id); @@ -480,6 +537,7 @@ static int dvb_usbv2_adapter_dvb_exit(struct dvb_usb_adapter *adap) adap->demux.dmx.close(&adap->demux.dmx); dvb_dmxdev_release(&adap->dmxdev); dvb_dmx_release(&adap->demux); + dvb_usbv2_media_device_unregister(d); dvb_unregister_adapter(&adap->dvb_adap); } @@ -643,6 +701,8 @@ static int dvb_usbv2_adapter_frontend_init(struct dvb_usb_adapter *adap) } } + dvb_create_media_graph(d->media_dev); + return 0; err_dvb_unregister_frontend: @@ -954,6 +1014,7 @@ void dvb_usbv2_disconnect(struct usb_interface *intf) struct dvb_usb_device *d = usb_get_intfdata(intf); const char *name = d->name; struct device dev = d->udev->dev; + dev_dbg(&d->udev->dev, "%s: bInterfaceNumber=%d\n", __func__, intf->cur_altsetting->desc.bInterfaceNumber);