Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4306282ybl; Mon, 13 Jan 2020 11:21:05 -0800 (PST) X-Google-Smtp-Source: APXvYqzDcGwAN82c5KCCxYbOQvpAjkWu5huy1UbVIN443cT7P9i8MAQ40vBqQc6PirGZLSKPULyp X-Received: by 2002:a05:6808:8d5:: with SMTP id k21mr14295866oij.121.1578943265568; Mon, 13 Jan 2020 11:21:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578943265; cv=none; d=google.com; s=arc-20160816; b=EMiuunwx6+bBY4k2qUbTebPG5NXSZvfCsBq4GLzHaOBd+G33dSB4cWPk+6x0+lLeaQ ZIyGni8vn5Rk0z/UuFzLobtVqOMFuWZVkV0Vr2sT0fIh6Xime6922l3iES30Niq7Hhib 7OUwnaEwT/eStG+zpkAIZ7RMjVxnQ6brsUDsTo+2PzCnQXP1fvWEM0IXKSR2qxNJKbbb ZV7Ziwyb8depaerzUUeZBgIHvo9KPhC+3KF9Djlg1DDxCj2PfBjuSuzRQzpZijkb53T4 aI0D7n3pwOE3fCL8B+jl8nm8T49KTnAxxOOEQaYZFBXY1eTWXunq/rF5XcXskyftPnoy +/3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=ASBacc11UDjEvtGQz0yfpf9DDj0sk2gjo77juUhpvYY=; b=HWF5Qu76DK4cpMwbE2BWSGGcczkuLmpmsMD63dLmrWgDyj2bQ/CP9isEnuuBUnVcoI 4FkAPSEYB+JNVn9QxqiHTQkR+mF0CuPY2glcQgJD5vNsa4xpzJffx0f7PqmlffXZYzQC q5B8eOvjxsWtGVeEGIW4T0+NlT510z5IG9xPyEQYXUMN484dv7rOblxV+GZbE1/6Uq/z kZLSG636sOHosMqovSP2Z/jdKBj1FsC8cfrqEoL0mQSgBlQwnz0IFTvbn0cvbymYHHfh PXJHDMKQ0DnhFM7vFJK44QZoNxx8W4Qy58c4YFNmMZO8RUN/IDEaCMC0oszlXzqD8kLF ffpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZtzkWaUl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z14si6707910oth.15.2020.01.13.11.20.53; Mon, 13 Jan 2020 11:21:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZtzkWaUl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728733AbgAMTTz (ORCPT + 99 others); Mon, 13 Jan 2020 14:19:55 -0500 Received: from mail-qt1-f195.google.com ([209.85.160.195]:33473 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726435AbgAMTTz (ORCPT ); Mon, 13 Jan 2020 14:19:55 -0500 Received: by mail-qt1-f195.google.com with SMTP id d5so10134631qto.0; Mon, 13 Jan 2020 11:19:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ASBacc11UDjEvtGQz0yfpf9DDj0sk2gjo77juUhpvYY=; b=ZtzkWaUl6pANKBajLxb7p395/gM1rca7butrEGrPmAAKs6seDHccE0bfdrYOO6vPBi +Nh8afEH4laDaJQylwgKIjFMHEqgGYKw+6DalOn/SZFOkHnF62ZjoFW4YV8sW5SXIFQD HKZNrUNubO9W3XUIbyoqbVEQzEujcCmofnqJNvJsF1UzBEfCKhYMfWkw8iuBs4rOyZSI uAGoDZqP9jGuJjem/Z7enGYnquHqxiLFTvZ1Di70GyUtJ6Wj8RteyMNFoWEdz435v0M/ 1/idcR3gAKc7/IrZG2PIWUo1Mwwvw9ITk9aKuOUNAtedoOSqFQEab9kcAsTq3fqoRJz+ vN7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ASBacc11UDjEvtGQz0yfpf9DDj0sk2gjo77juUhpvYY=; b=YZTwsyA2eu6Pz115msGuimsiD/BtMVkK9UeYL/3ke2BkEz9mO75TBJpiae5RAZ0+fc G1DJqdofPm68Ycuxg05GWccDauCfsysHy65gCF1Ov3+XvU3skTQvA+KH9jNoQTInvCnA 8O3SFd9E4evfr3c9KXzixzCt8odoSCBCbMNyojTSd06Jbwqj495+HJF3BZS+e+REQ8Lt KYywQJOyRZFdktWP+QvAk1yIGcKkAdImZsk9m5z4L5hkEIP+0Ik2GdjXAfy9gEZTKxsy zA7xC3SY7yGGLxiKFTt7dHl78i9Fdk9WLa2txDORUBNb6WKEpOJJHWngtlpIE+G3hqW6 /xfA== X-Gm-Message-State: APjAAAXJTnO4yGyDrpV2lUNvuixBBt8sPYrW2SNTGpkfAH0gRWbmsjZm S0DB3gWELCATGqC6v6XKAUDuM6MesnM= X-Received: by 2002:ac8:fae:: with SMTP id b43mr128567qtk.122.1578943193442; Mon, 13 Jan 2020 11:19:53 -0800 (PST) Received: from localhost.localdomain ([2804:14d:72b1:8920:a2ce:f815:f14d:bfac]) by smtp.gmail.com with ESMTPSA id g16sm5442320qkk.61.2020.01.13.11.19.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2020 11:19:52 -0800 (PST) From: "Daniel W. S. Almeida" X-Google-Original-From: Daniel W. S. Almeida To: mchehab@kernel.org, sean@mess.org, tglx@linutronix.de, gregkh@linuxfoundation.org Cc: "Daniel W. S. Almeida" , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, skhan@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org Subject: [PATCH v3] media: dvb_dummy_tuner: implement driver skeleton Date: Mon, 13 Jan 2020 16:19:39 -0300 Message-Id: <20200113191939.1555533-1-dwlsalmeida@gmail.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Daniel W. S. Almeida" The virtual DVB test driver serves as a reference DVB driver and helps validate the existing APIs in the media subsystem. It can also aid developers working on userspace applications. This dummy tuner should support common TV standards such as DVB-T/T2/S/S2, ISDB-T and ATSC when completed. For now, only a basic skeleton is available, most functions do nothing whatsoever. Signed-off-by: Daniel W. S. Almeida ----------------------------------------------------------- Changes in v3: KConfig: change config name to "Dummy DVB Media Tuner" remove useless 'default n' add module name on help, same as other drivers dvb_dummy_tuner.c: change license from GPL2+ to GPLv2. Remove LKMP reference from the source file Move the copyright notice to the top remove useless goto in dvb_tuner_i2c_probe only call i2c_set_clientdata after the pointer is ready remove dvb_dummy_tuner.h as it was not needed Fix this error: WARNING: Possible unwrapped commit description (prefer a maximum 75 chars per line) #15: validate the existing APIs in the media subsystem. It can also aid developers Remove LKMP reference from commit message Changes in v2: Commit message was rewritten Added better description in KConfig Added better description in .h and .c Added copyright notice in .h and .c Kconfig dummy tuner option now defaults to 'n' Removed calls to pr_err, pr_debug ------------------------------------------------------------ drivers/media/tuners/Kconfig | 9 ++ drivers/media/tuners/Makefile | 1 + drivers/media/tuners/dvb_dummy_tuner.c | 153 +++++++++++++++++++++++++ 3 files changed, 163 insertions(+) create mode 100644 drivers/media/tuners/dvb_dummy_tuner.c diff --git a/drivers/media/tuners/Kconfig b/drivers/media/tuners/Kconfig index e104bb7766e1..8ad54339ceee 100644 --- a/drivers/media/tuners/Kconfig +++ b/drivers/media/tuners/Kconfig @@ -296,4 +296,13 @@ config MEDIA_TUNER_QM1D1B0004 default m if !MEDIA_SUBDRV_AUTOSELECT help Sharp QM1D1B0004 ISDB-S tuner driver. + +config MEDIA_TUNER_DVB_DUMMY_TUNER + tristate "Dummy DVB Media Tuner" + depends on MEDIA_SUPPORT && I2C + help + Dummy DVB media tuner driver + The virtual DVB test driver serves as a reference DVB driver and helps + validate the existing APIs in the media subsystem. It can also aid + developers working on userspace applications. endmenu diff --git a/drivers/media/tuners/Makefile b/drivers/media/tuners/Makefile index 7b4f8423501e..f98de1cf2e19 100644 --- a/drivers/media/tuners/Makefile +++ b/drivers/media/tuners/Makefile @@ -44,5 +44,6 @@ obj-$(CONFIG_MEDIA_TUNER_QM1D1C0042) += qm1d1c0042.o obj-$(CONFIG_MEDIA_TUNER_QM1D1B0004) += qm1d1b0004.o obj-$(CONFIG_MEDIA_TUNER_M88RS6000T) += m88rs6000t.o obj-$(CONFIG_MEDIA_TUNER_TDA18250) += tda18250.o +obj-$(CONFIG_MEDIA_TUNER_DVB_DUMMY_TUNER) += dvb_dummy_tuner.o ccflags-y += -I$(srctree)/drivers/media/dvb-frontends diff --git a/drivers/media/tuners/dvb_dummy_tuner.c b/drivers/media/tuners/dvb_dummy_tuner.c new file mode 100644 index 000000000000..7c61270fe3f2 --- /dev/null +++ b/drivers/media/tuners/dvb_dummy_tuner.c @@ -0,0 +1,153 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2020 Daniel W. S. Almeida + * + * The virtual DVB test driver serves as a reference DVB driver and helps + * validate the existing APIs in the media subsystem. It can also aid + * developers working on userspace applications. + * + * This dummy tuner should support common TV standards such as + * DVB-T/T2/S/S2, ISDB-T and ATSC when completed. + * + */ + +#include +#include +#include +#include +#include +#include +#include "dvb_dummy_tuner.h" + +struct dvb_dummy_tuner_dev { + struct dvb_frontend *fe; +}; + +static void dvb_dummy_tuner_release(struct dvb_frontend *fe) +{ +} + +static int dvb_dummy_tuner_init(struct dvb_frontend *fe) +{ + return 0; +} + +static int dvb_dummy_tuner_sleep(struct dvb_frontend *fe) +{ + return 0; +} + +static int dvb_dummy_tuner_suspend(struct dvb_frontend *fe) +{ + return 0; +} + +static int dvb_dummy_tuner_resume(struct dvb_frontend *fe) +{ + return 0; +} + +static int dvb_dummy_tuner_set_params(struct dvb_frontend *fe) +{ + return 0; +} + +static int dvb_dummy_tuner_set_config(struct dvb_frontend *fe, + void *priv_cfg) +{ + return 0; +} + +static int dvb_dummy_tuner_get_frequency(struct dvb_frontend *fe, + u32 *frequency) +{ + return 0; +} + +static int dvb_dummy_tuner_get_bandwidth(struct dvb_frontend *fe, + u32 *bandwidth) +{ + return 0; +} + +static int dvb_dummy_tuner_get_if_frequency(struct dvb_frontend *fe, + u32 *frequency) +{ + return 0; +} + +static int dvb_dummy_tuner_get_status(struct dvb_frontend *fe, u32 *status) +{ + return 0; +} + +static const struct dvb_tuner_ops dvb_dummy_tuner_ops = { + .release = dvb_dummy_tuner_release, + .init = dvb_dummy_tuner_init, + .sleep = dvb_dummy_tuner_sleep, + .suspend = dvb_dummy_tuner_suspend, + .resume = dvb_dummy_tuner_resume, + .set_params = dvb_dummy_tuner_set_params, + .set_config = dvb_dummy_tuner_set_config, + .get_bandwidth = dvb_dummy_tuner_get_bandwidth, + .get_frequency = dvb_dummy_tuner_get_frequency, + .get_if_frequency = dvb_dummy_tuner_get_if_frequency, + .get_status = dvb_dummy_tuner_get_status, +}; + +static const struct i2c_device_id dvb_dummy_tuner_i2c_id_table[] = { + {"dvb_dummy_tuner", 0}, + {} +}; +MODULE_DEVICE_TABLE(i2c, dvb_dummy_tuner_i2c_id_table); + +static int dvb_dummy_tuner_i2c_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct dvb_dummy_tuner_config *config = client->dev.platform_data; + struct dvb_frontend *fe = config->fe; + struct dvb_dummy_tuner_dev *tuner_dev = NULL; + + tuner_dev = kzalloc(sizeof(*tuner_dev), GFP_KERNEL); + if (!tuner_dev) + return -ENOMEM; + + tuner_dev->fe = config->fe; + i2c_set_clientdata(client, tuner_dev); + + memcpy(&fe->ops.tuner_ops, + &dvb_dummy_tuner_ops, + sizeof(struct dvb_tuner_ops)); + + fe->tuner_priv = client; + + return 0; + +} + +static int dvb_dummy_tuner_i2c_remove(struct i2c_client *client) +{ + struct dvb_dummy_tuner_dev *tuner_dev = i2c_get_clientdata(client); + struct dvb_frontend *fe = tuner_dev->fe; + + memset(&fe->ops.tuner_ops, 0, sizeof(struct dvb_tuner_ops)); + fe->tuner_priv = NULL; + kfree(tuner_dev); + + return 0; +} + +static struct i2c_driver dvb_dummy_tuner_i2c_driver = { + .driver = { + .name = "dvb_dummy_tuner", + .suppress_bind_attrs = true, + }, + .probe = dvb_dummy_tuner_i2c_probe, + .remove = dvb_dummy_tuner_i2c_remove, + .id_table = dvb_dummy_tuner_i2c_id_table, +}; +module_i2c_driver(dvb_dummy_tuner_i2c_driver); + +MODULE_DESCRIPTION("DVB Dummy Tuner"); +MODULE_AUTHOR("Daniel W. S. Almeida"); +MODULE_LICENSE("GPL"); -- 2.24.1