On Wed, Dec 25, 2024 at 01:10:10AM +0200, Dmitry Baryshkov wrote:
> Add generic CEC helpers to be used by HDMI drivers. Both notifier and
> and adapter are supported for registration. Once registered, the driver
> can call common set of functions to update physical address, to
> invalidate it or to unregister CEC data.
> 
> Signed-off-by: Dmitry Baryshkov <[email protected]>
> ---
>  drivers/gpu/drm/display/Kconfig               |   5 +
>  drivers/gpu/drm/display/Makefile              |   2 +
>  drivers/gpu/drm/display/drm_hdmi_cec_helper.c | 145 
> ++++++++++++++++++++++++++
>  include/drm/display/drm_hdmi_cec_helper.h     |  38 +++++++
>  4 files changed, 190 insertions(+)
> 
> diff --git a/drivers/gpu/drm/display/Kconfig b/drivers/gpu/drm/display/Kconfig
> index 
> 8d22b7627d41f7bc015decf24ae02a05bc00f055..49da9b768acf3e5f84f2cefae4bb042cfd57a50c
>  100644
> --- a/drivers/gpu/drm/display/Kconfig
> +++ b/drivers/gpu/drm/display/Kconfig
> @@ -82,6 +82,11 @@ config DRM_DISPLAY_HDMI_AUDIO_HELPER
>         DRM display helpers for HDMI Audio functionality (generic HDMI Codec
>         implementation).
>  
> +config DRM_DISPLAY_HDMI_CEC_HELPER
> +     bool
> +     help
> +       DRM display helpers for HDMI CEC implementation.
> +
>  config DRM_DISPLAY_HDMI_HELPER
>       bool
>       help
> diff --git a/drivers/gpu/drm/display/Makefile 
> b/drivers/gpu/drm/display/Makefile
> index 
> b17879b957d5401721396e247fa346387cf6c48a..2cd078e2b81c1a9e6b336c4187b444bcb8a50e51
>  100644
> --- a/drivers/gpu/drm/display/Makefile
> +++ b/drivers/gpu/drm/display/Makefile
> @@ -16,6 +16,8 @@ drm_display_helper-$(CONFIG_DRM_DISPLAY_DSC_HELPER) += \
>  drm_display_helper-$(CONFIG_DRM_DISPLAY_HDCP_HELPER) += drm_hdcp_helper.o
>  drm_display_helper-$(CONFIG_DRM_DISPLAY_HDMI_AUDIO_HELPER) += \
>       drm_hdmi_audio_helper.o
> +drm_display_helper-$(CONFIG_DRM_DISPLAY_HDMI_CEC_HELPER) += \
> +     drm_hdmi_cec_helper.o
>  drm_display_helper-$(CONFIG_DRM_DISPLAY_HDMI_HELPER) += \
>       drm_hdmi_helper.o \
>       drm_scdc_helper.o
> diff --git a/drivers/gpu/drm/display/drm_hdmi_cec_helper.c 
> b/drivers/gpu/drm/display/drm_hdmi_cec_helper.c
> new file mode 100644
> index 
> 0000000000000000000000000000000000000000..2a3832e68232fa3b839a3c7457b2013779cada86
> --- /dev/null
> +++ b/drivers/gpu/drm/display/drm_hdmi_cec_helper.c
> @@ -0,0 +1,145 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright (c) 2024 Linaro Ltd
> + */
> +
> +#include <drm/drm_bridge.h>
> +#include <drm/drm_connector.h>
> +#include <drm/display/drm_hdmi_cec_helper.h>
> +
> +#include <linux/mutex.h>
> +
> +#include <media/cec.h>
> +#include <media/cec-notifier.h>
> +
> +static void drm_connector_hdmi_cec_adapter_unregister(struct drm_connector 
> *connector)
> +{
> +     cec_unregister_adapter(connector->cec.adapter);
> +     connector->cec.adapter = NULL;
> +     connector->cec.unregister = NULL;
> +}
> +
> +int drm_connector_hdmi_cec_adapter_register(struct drm_connector *connector,
> +                                         const struct cec_adap_ops *ops,
> +                                         const char *name,
> +                                         u8 available_las,
> +                                         int (*init_cec)(struct 
> drm_connector *connector),
> +                                         void (*uninit_cec)(struct 
> drm_connector *connector),
> +                                         struct device *dev)

We're missing a documentation here. Why do we need drivers to pass both
a set of cec_adap_ops and a bunch of extra functions? Shouldn't we make
this a single structure like we did for audio?

Also, to remain consistent, we should call that function 
drm_connector_hdmi_cec_register


Maxime

Attachment: signature.asc
Description: PGP signature

Reply via email to