From: laurent.pinchart@ideasonboard.com (Laurent Pinchart)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 3/4] drm/bridge: dw-hdmi: add cec driver
Date: Wed, 02 Aug 2017 01:32:40 +0300 [thread overview]
Message-ID: <1884159.hmXKyeR78T@avalon> (raw)
In-Reply-To: <E1dcBhf-00088t-Os@rmk-PC.armlinux.org.uk>
Hi Russell,
Thank you for the patch.
On Monday 31 Jul 2017 15:29:51 Russell King wrote:
> Add a CEC driver for the dw-hdmi hardware.
>
> Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
> drivers/gpu/drm/bridge/synopsys/Kconfig | 9 +
> drivers/gpu/drm/bridge/synopsys/Makefile | 1 +
> drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c | 326 +++++++++++++++++++++++
> drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.h | 19 ++
> drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 42 +++-
> drivers/gpu/drm/bridge/synopsys/dw-hdmi.h | 1 +
> 6 files changed, 397 insertions(+), 1 deletion(-)
> create mode 100644 drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c
> create mode 100644 drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.h
[snip]
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c
> b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c new file mode 100644
> index 000000000000..52c9d93b9602
> --- /dev/null
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c
[snip]
> +static int dw_hdmi_cec_probe(struct platform_device *pdev)
> +{
> + struct dw_hdmi_cec_data *data = dev_get_platdata(&pdev->dev);
> + struct dw_hdmi_cec *cec;
> + int ret;
> +
> + if (!data)
> + return -ENXIO;
> +
> + /*
> + * Our device is just a convenience - we want to link to the real
> + * hardware device here, so that userspace can see the association
> + * between the HDMI hardware and its associated CEC chardev.
> + */
> + cec = devm_kzalloc(&pdev->dev, sizeof(*cec), GFP_KERNEL);
> + if (!cec)
> + return -ENOMEM;
> +
> + cec->irq = data->irq;
> + cec->ops = data->ops;
> + cec->hdmi = data->hdmi;
> +
> + platform_set_drvdata(pdev, cec);
> +
> + dw_hdmi_write(cec, 0, HDMI_CEC_TX_CNT);
> + dw_hdmi_write(cec, ~0, HDMI_CEC_MASK);
> + dw_hdmi_write(cec, ~0, HDMI_IH_MUTE_CEC_STAT0);
> + dw_hdmi_write(cec, 0, HDMI_CEC_POLARITY);
> +
> + cec->adap = cec_allocate_adapter(&dw_hdmi_cec_ops, cec, "dw_hdmi",
> + CEC_CAP_LOG_ADDRS | CEC_CAP_TRANSMIT
|
> + CEC_CAP_RC, CEC_MAX_LOG_ADDRS);
> + if (IS_ERR(cec->adap))
> + return PTR_ERR(cec->adap);
> +
> + /* override the module pointer */
> + cec->adap->owner = THIS_MODULE;
> +
> + ret = devm_add_action(&pdev->dev, dw_hdmi_cec_del, cec);
> + if (ret) {
> + cec_delete_adapter(cec->adap);
> + return ret;
> + }
> +
> + ret = devm_request_threaded_irq(&pdev->dev, cec->irq,
> + dw_hdmi_cec_hardirq,
> + dw_hdmi_cec_thread, IRQF_SHARED,
> + "dw-hdmi-cec", cec->adap);
> + if (ret < 0)
> + return ret;
> +
> + cec->notify = cec_notifier_get(pdev->dev.parent);
> + if (!cec->notify)
> + return -ENOMEM;
> +
> + ret = cec_register_adapter(cec->adap, pdev->dev.parent);
> + if (ret < 0) {
> + cec_notifier_put(cec->notify);
> + return ret;
> + }
> +
> + /*
> + * CEC documentation says we must not call cec_delete_adapter
> + * after a successful call to cec_register_adapter().
> + */
> + devm_remove_action(&pdev->dev, dw_hdmi_cec_del, cec);
dw_hdmi_cec_del() is only used to clean up in the error path of the probe
function. It would be simpler and less resource-consuming to add an error
label to this function instead of using devm.
> +
> + cec_register_cec_notifier(cec->adap, cec->notify);
> +
> + return 0;
> +}
> +
> +static int dw_hdmi_cec_remove(struct platform_device *pdev)
> +{
> + struct dw_hdmi_cec *cec = platform_get_drvdata(pdev);
> +
> + cec_unregister_adapter(cec->adap);
> + cec_notifier_put(cec->notify);
> +
> + return 0;
> +}
> +
> +static struct platform_driver dw_hdmi_cec_driver = {
> + .probe = dw_hdmi_cec_probe,
> + .remove = dw_hdmi_cec_remove,
> + .driver = {
> + .name = "dw-hdmi-cec",
> + },
> +};
> +module_platform_driver(dw_hdmi_cec_driver);
Is there a particular reason why this has to be a separate module instead of
simply calling the CEC init/cleanup functions directly from the main dw-hdmi
driver ?
> +MODULE_AUTHOR("Russell King <rmk+kernel@armlinux.org.uk>");
> +MODULE_DESCRIPTION("Synopsys Designware HDMI CEC driver for i.MX");
> +MODULE_LICENSE("GPL");
> +MODULE_ALIAS(PLATFORM_MODULE_PREFIX "dw-hdmi-cec");
--
Regards,
Laurent Pinchart
WARNING: multiple messages have this Message-ID (diff)
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: dri-devel@lists.freedesktop.org
Cc: Hans Verkuil <hverkuil@xs4all.nl>,
Russell King <rmk+kernel@armlinux.org.uk>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 3/4] drm/bridge: dw-hdmi: add cec driver
Date: Wed, 02 Aug 2017 01:32:40 +0300 [thread overview]
Message-ID: <1884159.hmXKyeR78T@avalon> (raw)
In-Reply-To: <E1dcBhf-00088t-Os@rmk-PC.armlinux.org.uk>
Hi Russell,
Thank you for the patch.
On Monday 31 Jul 2017 15:29:51 Russell King wrote:
> Add a CEC driver for the dw-hdmi hardware.
>
> Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
> drivers/gpu/drm/bridge/synopsys/Kconfig | 9 +
> drivers/gpu/drm/bridge/synopsys/Makefile | 1 +
> drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c | 326 +++++++++++++++++++++++
> drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.h | 19 ++
> drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 42 +++-
> drivers/gpu/drm/bridge/synopsys/dw-hdmi.h | 1 +
> 6 files changed, 397 insertions(+), 1 deletion(-)
> create mode 100644 drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c
> create mode 100644 drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.h
[snip]
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c
> b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c new file mode 100644
> index 000000000000..52c9d93b9602
> --- /dev/null
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c
[snip]
> +static int dw_hdmi_cec_probe(struct platform_device *pdev)
> +{
> + struct dw_hdmi_cec_data *data = dev_get_platdata(&pdev->dev);
> + struct dw_hdmi_cec *cec;
> + int ret;
> +
> + if (!data)
> + return -ENXIO;
> +
> + /*
> + * Our device is just a convenience - we want to link to the real
> + * hardware device here, so that userspace can see the association
> + * between the HDMI hardware and its associated CEC chardev.
> + */
> + cec = devm_kzalloc(&pdev->dev, sizeof(*cec), GFP_KERNEL);
> + if (!cec)
> + return -ENOMEM;
> +
> + cec->irq = data->irq;
> + cec->ops = data->ops;
> + cec->hdmi = data->hdmi;
> +
> + platform_set_drvdata(pdev, cec);
> +
> + dw_hdmi_write(cec, 0, HDMI_CEC_TX_CNT);
> + dw_hdmi_write(cec, ~0, HDMI_CEC_MASK);
> + dw_hdmi_write(cec, ~0, HDMI_IH_MUTE_CEC_STAT0);
> + dw_hdmi_write(cec, 0, HDMI_CEC_POLARITY);
> +
> + cec->adap = cec_allocate_adapter(&dw_hdmi_cec_ops, cec, "dw_hdmi",
> + CEC_CAP_LOG_ADDRS | CEC_CAP_TRANSMIT
|
> + CEC_CAP_RC, CEC_MAX_LOG_ADDRS);
> + if (IS_ERR(cec->adap))
> + return PTR_ERR(cec->adap);
> +
> + /* override the module pointer */
> + cec->adap->owner = THIS_MODULE;
> +
> + ret = devm_add_action(&pdev->dev, dw_hdmi_cec_del, cec);
> + if (ret) {
> + cec_delete_adapter(cec->adap);
> + return ret;
> + }
> +
> + ret = devm_request_threaded_irq(&pdev->dev, cec->irq,
> + dw_hdmi_cec_hardirq,
> + dw_hdmi_cec_thread, IRQF_SHARED,
> + "dw-hdmi-cec", cec->adap);
> + if (ret < 0)
> + return ret;
> +
> + cec->notify = cec_notifier_get(pdev->dev.parent);
> + if (!cec->notify)
> + return -ENOMEM;
> +
> + ret = cec_register_adapter(cec->adap, pdev->dev.parent);
> + if (ret < 0) {
> + cec_notifier_put(cec->notify);
> + return ret;
> + }
> +
> + /*
> + * CEC documentation says we must not call cec_delete_adapter
> + * after a successful call to cec_register_adapter().
> + */
> + devm_remove_action(&pdev->dev, dw_hdmi_cec_del, cec);
dw_hdmi_cec_del() is only used to clean up in the error path of the probe
function. It would be simpler and less resource-consuming to add an error
label to this function instead of using devm.
> +
> + cec_register_cec_notifier(cec->adap, cec->notify);
> +
> + return 0;
> +}
> +
> +static int dw_hdmi_cec_remove(struct platform_device *pdev)
> +{
> + struct dw_hdmi_cec *cec = platform_get_drvdata(pdev);
> +
> + cec_unregister_adapter(cec->adap);
> + cec_notifier_put(cec->notify);
> +
> + return 0;
> +}
> +
> +static struct platform_driver dw_hdmi_cec_driver = {
> + .probe = dw_hdmi_cec_probe,
> + .remove = dw_hdmi_cec_remove,
> + .driver = {
> + .name = "dw-hdmi-cec",
> + },
> +};
> +module_platform_driver(dw_hdmi_cec_driver);
Is there a particular reason why this has to be a separate module instead of
simply calling the CEC init/cleanup functions directly from the main dw-hdmi
driver ?
> +MODULE_AUTHOR("Russell King <rmk+kernel@armlinux.org.uk>");
> +MODULE_DESCRIPTION("Synopsys Designware HDMI CEC driver for i.MX");
> +MODULE_LICENSE("GPL");
> +MODULE_ALIAS(PLATFORM_MODULE_PREFIX "dw-hdmi-cec");
--
Regards,
Laurent Pinchart
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2017-08-01 22:32 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-31 14:29 [PATCH v2 0/4] dw-hdmi CEC support Russell King - ARM Linux
2017-07-31 14:29 ` Russell King - ARM Linux
2017-07-31 14:29 ` [PATCH v2 1/4] drm/bridge: dw-hdmi: add cec notifier support Russell King
2017-07-31 14:29 ` Russell King
2017-07-31 14:33 ` Neil Armstrong
2017-07-31 14:33 ` Neil Armstrong
2017-07-31 15:25 ` Hans Verkuil
2017-07-31 15:25 ` Hans Verkuil
2017-08-04 13:36 ` Archit Taneja
2017-08-04 13:36 ` Archit Taneja
2017-08-05 9:23 ` Hans Verkuil
2017-08-05 9:23 ` Hans Verkuil
2017-08-07 3:59 ` Archit Taneja
2017-08-07 3:59 ` Archit Taneja
2017-08-02 14:11 ` Laurent Pinchart
2017-08-02 14:11 ` Laurent Pinchart
2017-08-02 14:17 ` Hans Verkuil
2017-08-02 14:17 ` Hans Verkuil
2017-08-02 17:44 ` Russell King - ARM Linux
2017-08-02 17:44 ` Russell King - ARM Linux
2017-07-31 14:29 ` [PATCH v2 2/4] drm/bridge: dw-hdmi: add better clock disable control Russell King
2017-07-31 14:29 ` Russell King
2017-07-31 15:26 ` Hans Verkuil
2017-07-31 15:26 ` Hans Verkuil
2017-08-04 13:39 ` Archit Taneja
2017-08-04 13:39 ` Archit Taneja
2017-07-31 14:29 ` [PATCH v2 3/4] drm/bridge: dw-hdmi: add cec driver Russell King
2017-07-31 14:29 ` Russell King
2017-07-31 15:35 ` Hans Verkuil
2017-07-31 15:35 ` Hans Verkuil
2017-08-01 22:32 ` Laurent Pinchart [this message]
2017-08-01 22:32 ` Laurent Pinchart
2017-08-02 6:47 ` Hans Verkuil
2017-08-02 6:47 ` Hans Verkuil
2017-08-02 13:14 ` Laurent Pinchart
2017-08-02 13:14 ` Laurent Pinchart
2017-08-02 13:27 ` Russell King - ARM Linux
2017-08-02 13:27 ` Russell King - ARM Linux
2017-08-02 13:34 ` Hans Verkuil
2017-08-02 13:34 ` Hans Verkuil
2017-08-02 14:22 ` Laurent Pinchart
2017-08-02 14:22 ` Laurent Pinchart
2017-08-02 17:43 ` Russell King - ARM Linux
2017-08-02 17:43 ` Russell King - ARM Linux
2017-08-02 14:17 ` Neil Armstrong
2017-07-31 14:29 ` [PATCH v2 4/4] drm/bridge: dw-hdmi: remove CEC engine register definitions Russell King
2017-07-31 14:29 ` Russell King
2017-07-31 15:26 ` Hans Verkuil
2017-07-31 15:26 ` Hans Verkuil
2017-08-01 22:29 ` [PATCH v2 0/4] dw-hdmi CEC support Laurent Pinchart
2017-08-01 22:29 ` Laurent Pinchart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1884159.hmXKyeR78T@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.