diff mbox series

[v2] drm/mediatek: Add ovl_adaptor get format function

Message ID 20230329015916.21684-1-nancy.lin@mediatek.com (mailing list archive)
State New, archived
Headers show
Series [v2] drm/mediatek: Add ovl_adaptor get format function | expand

Commit Message

Nancy Lin (林欣螢) March 29, 2023, 1:59 a.m. UTC
Add ovl_adaptor get_format and get_num_formats component function.
The two functions are need for getting the supported format in
mtk_plane_init().

Signed-off-by: Nancy.Lin <nancy.lin@mediatek.com>
---
 drivers/gpu/drm/mediatek/mtk_disp_drv.h       |  2 ++
 .../gpu/drm/mediatek/mtk_disp_ovl_adaptor.c   | 24 +++++++++++++++++++
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c   |  2 ++
 3 files changed, 28 insertions(+)

Comments

CK Hu (胡俊光) March 29, 2023, 8:15 a.m. UTC | #1
Hi, Nancy:

On Wed, 2023-03-29 at 09:59 +0800, Nancy.Lin wrote:
> Add ovl_adaptor get_format and get_num_formats component function.
> The two functions are need for getting the supported format in
> mtk_plane_init().
> 
> Signed-off-by: Nancy.Lin <nancy.lin@mediatek.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_disp_drv.h       |  2 ++
>  .../gpu/drm/mediatek/mtk_disp_ovl_adaptor.c   | 24
> +++++++++++++++++++
>  drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c   |  2 ++
>  3 files changed, 28 insertions(+)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_disp_drv.h
> b/drivers/gpu/drm/mediatek/mtk_disp_drv.h
> index 0d28b2e2069c..da2de17b84e9 100644
> --- a/drivers/gpu/drm/mediatek/mtk_disp_drv.h
> +++ b/drivers/gpu/drm/mediatek/mtk_disp_drv.h
> @@ -124,6 +124,8 @@ void mtk_ovl_adaptor_start(struct device *dev);
>  void mtk_ovl_adaptor_stop(struct device *dev);
>  unsigned int mtk_ovl_adaptor_layer_nr(struct device *dev);
>  struct device *mtk_ovl_adaptor_dma_dev_get(struct device *dev);
> +const u32 *mtk_ovl_adaptor_get_formats(struct device *dev);
> +size_t mtk_ovl_adaptor_get_num_formats(struct device *dev);
>  
>  void mtk_rdma_bypass_shadow(struct device *dev);
>  int mtk_rdma_clk_enable(struct device *dev);
> diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c
> b/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c
> index 046217828ab3..b5d28c392c57 100644
> --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c
> +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c
> @@ -25,6 +25,20 @@
>  #define MTK_OVL_ADAPTOR_RDMA_MAX_WIDTH 1920
>  #define MTK_OVL_ADAPTOR_LAYER_NUM 4
>  
> +static const u32 formats[] = {
> +	DRM_FORMAT_XRGB8888,
> +	DRM_FORMAT_ARGB8888,
> +	DRM_FORMAT_BGRX8888,
> +	DRM_FORMAT_BGRA8888,
> +	DRM_FORMAT_ABGR8888,
> +	DRM_FORMAT_XBGR8888,
> +	DRM_FORMAT_RGB888,
> +	DRM_FORMAT_BGR888,
> +	DRM_FORMAT_RGB565,
> +	DRM_FORMAT_UYVY,
> +	DRM_FORMAT_YUYV,
> +};
> +
>  enum mtk_ovl_adaptor_comp_type {
>  	OVL_ADAPTOR_TYPE_RDMA = 0,
>  	OVL_ADAPTOR_TYPE_MERGE,
> @@ -297,6 +311,16 @@ void mtk_ovl_adaptor_disable_vblank(struct
> device *dev)
>  	mtk_ethdr_disable_vblank(ovl_adaptor-
> >ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0]);
>  }
>  
> +const u32 *mtk_ovl_adaptor_get_formats(struct device *dev)
> +{
> +	return formats;

The supported formats depend on the mdp-rdma hardware capability, so
get formats from mdp-rdma driver.

Regards,
CK

> +}
> +
> +size_t mtk_ovl_adaptor_get_num_formats(struct device *dev)
> +{
> +	return ARRAY_SIZE(formats);
> +}
> +
>  void mtk_ovl_adaptor_add_comp(struct device *dev, struct mtk_mutex
> *mutex)
>  {
>  	mtk_mutex_add_comp(mutex, DDP_COMPONENT_MDP_RDMA0);
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> index 1a0c4f7e352a..f114da4d36a9 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> @@ -410,6 +410,8 @@ static const struct mtk_ddp_comp_funcs
> ddp_ovl_adaptor = {
>  	.disconnect = mtk_ovl_adaptor_disconnect,
>  	.add = mtk_ovl_adaptor_add_comp,
>  	.remove = mtk_ovl_adaptor_remove_comp,
> +	.get_formats = mtk_ovl_adaptor_get_formats,
> +	.get_num_formats = mtk_ovl_adaptor_get_num_formats,
>  };
>  
>  static const char * const mtk_ddp_comp_stem[MTK_DDP_COMP_TYPE_MAX] =
> {
AngeloGioacchino Del Regno March 29, 2023, 1:07 p.m. UTC | #2
Il 29/03/23 03:59, Nancy.Lin ha scritto:
> Add ovl_adaptor get_format and get_num_formats component function.
> The two functions are need for getting the supported format in
> mtk_plane_init().
> 
> Signed-off-by: Nancy.Lin <nancy.lin@mediatek.com>

Small note:

This commit depends on
f287c66a6064 ("drm/mediatek: Refactor pixel format logic")

...that was already applied in the maintainer's tree.

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

[On MT8195 Cherry Tomato]
Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

Regards,
Angelo
Nancy Lin (林欣螢) March 30, 2023, 1:48 a.m. UTC | #3
Hi CK,

Thanks for the review.

On Wed, 2023-03-29 at 08:15 +0000, CK Hu (胡俊光) wrote:
> Hi, Nancy:
> 
> On Wed, 2023-03-29 at 09:59 +0800, Nancy.Lin wrote:
> > Add ovl_adaptor get_format and get_num_formats component function.
> > The two functions are need for getting the supported format in
> > mtk_plane_init().
> > 
> > Signed-off-by: Nancy.Lin <nancy.lin@mediatek.com>
> > ---
> >  drivers/gpu/drm/mediatek/mtk_disp_drv.h       |  2 ++
> >  .../gpu/drm/mediatek/mtk_disp_ovl_adaptor.c   | 24
> > +++++++++++++++++++
> >  drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c   |  2 ++
> >  3 files changed, 28 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/mediatek/mtk_disp_drv.h
> > b/drivers/gpu/drm/mediatek/mtk_disp_drv.h
> > index 0d28b2e2069c..da2de17b84e9 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_disp_drv.h
> > +++ b/drivers/gpu/drm/mediatek/mtk_disp_drv.h
> > @@ -124,6 +124,8 @@ void mtk_ovl_adaptor_start(struct device *dev);
> >  void mtk_ovl_adaptor_stop(struct device *dev);
> >  unsigned int mtk_ovl_adaptor_layer_nr(struct device *dev);
> >  struct device *mtk_ovl_adaptor_dma_dev_get(struct device *dev);
> > +const u32 *mtk_ovl_adaptor_get_formats(struct device *dev);
> > +size_t mtk_ovl_adaptor_get_num_formats(struct device *dev);
> >  
> >  void mtk_rdma_bypass_shadow(struct device *dev);
> >  int mtk_rdma_clk_enable(struct device *dev);
> > diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c
> > b/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c
> > index 046217828ab3..b5d28c392c57 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c
> > +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c
> > @@ -25,6 +25,20 @@
> >  #define MTK_OVL_ADAPTOR_RDMA_MAX_WIDTH 1920
> >  #define MTK_OVL_ADAPTOR_LAYER_NUM 4
> >  
> > +static const u32 formats[] = {
> > +	DRM_FORMAT_XRGB8888,
> > +	DRM_FORMAT_ARGB8888,
> > +	DRM_FORMAT_BGRX8888,
> > +	DRM_FORMAT_BGRA8888,
> > +	DRM_FORMAT_ABGR8888,
> > +	DRM_FORMAT_XBGR8888,
> > +	DRM_FORMAT_RGB888,
> > +	DRM_FORMAT_BGR888,
> > +	DRM_FORMAT_RGB565,
> > +	DRM_FORMAT_UYVY,
> > +	DRM_FORMAT_YUYV,
> > +};
> > +
> >  enum mtk_ovl_adaptor_comp_type {
> >  	OVL_ADAPTOR_TYPE_RDMA = 0,
> >  	OVL_ADAPTOR_TYPE_MERGE,
> > @@ -297,6 +311,16 @@ void mtk_ovl_adaptor_disable_vblank(struct
> > device *dev)
> >  	mtk_ethdr_disable_vblank(ovl_adaptor-
> > > ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0]);
> > 
> >  }
> >  
> > +const u32 *mtk_ovl_adaptor_get_formats(struct device *dev)
> > +{
> > +	return formats;
> 
> The supported formats depend on the mdp-rdma hardware capability, so
> get formats from mdp-rdma driver.
> 
> Regards,
> CK
> 
OK, I will add mdp-rdma supported format api for ovl_adaptor.

Regards,
Nancy

> > +}
> > +
> > +size_t mtk_ovl_adaptor_get_num_formats(struct device *dev)
> > +{
> > +	return ARRAY_SIZE(formats);
> > +}
> > +
> >  void mtk_ovl_adaptor_add_comp(struct device *dev, struct mtk_mutex
> > *mutex)
> >  {
> >  	mtk_mutex_add_comp(mutex, DDP_COMPONENT_MDP_RDMA0);
> > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> > b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> > index 1a0c4f7e352a..f114da4d36a9 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> > +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> > @@ -410,6 +410,8 @@ static const struct mtk_ddp_comp_funcs
> > ddp_ovl_adaptor = {
> >  	.disconnect = mtk_ovl_adaptor_disconnect,
> >  	.add = mtk_ovl_adaptor_add_comp,
> >  	.remove = mtk_ovl_adaptor_remove_comp,
> > +	.get_formats = mtk_ovl_adaptor_get_formats,
> > +	.get_num_formats = mtk_ovl_adaptor_get_num_formats,
> >  };
> >  
> >  static const char * const mtk_ddp_comp_stem[MTK_DDP_COMP_TYPE_MAX]
> > =
> > {
diff mbox series

Patch

diff --git a/drivers/gpu/drm/mediatek/mtk_disp_drv.h b/drivers/gpu/drm/mediatek/mtk_disp_drv.h
index 0d28b2e2069c..da2de17b84e9 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_drv.h
+++ b/drivers/gpu/drm/mediatek/mtk_disp_drv.h
@@ -124,6 +124,8 @@  void mtk_ovl_adaptor_start(struct device *dev);
 void mtk_ovl_adaptor_stop(struct device *dev);
 unsigned int mtk_ovl_adaptor_layer_nr(struct device *dev);
 struct device *mtk_ovl_adaptor_dma_dev_get(struct device *dev);
+const u32 *mtk_ovl_adaptor_get_formats(struct device *dev);
+size_t mtk_ovl_adaptor_get_num_formats(struct device *dev);
 
 void mtk_rdma_bypass_shadow(struct device *dev);
 int mtk_rdma_clk_enable(struct device *dev);
diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c
index 046217828ab3..b5d28c392c57 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c
+++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c
@@ -25,6 +25,20 @@ 
 #define MTK_OVL_ADAPTOR_RDMA_MAX_WIDTH 1920
 #define MTK_OVL_ADAPTOR_LAYER_NUM 4
 
+static const u32 formats[] = {
+	DRM_FORMAT_XRGB8888,
+	DRM_FORMAT_ARGB8888,
+	DRM_FORMAT_BGRX8888,
+	DRM_FORMAT_BGRA8888,
+	DRM_FORMAT_ABGR8888,
+	DRM_FORMAT_XBGR8888,
+	DRM_FORMAT_RGB888,
+	DRM_FORMAT_BGR888,
+	DRM_FORMAT_RGB565,
+	DRM_FORMAT_UYVY,
+	DRM_FORMAT_YUYV,
+};
+
 enum mtk_ovl_adaptor_comp_type {
 	OVL_ADAPTOR_TYPE_RDMA = 0,
 	OVL_ADAPTOR_TYPE_MERGE,
@@ -297,6 +311,16 @@  void mtk_ovl_adaptor_disable_vblank(struct device *dev)
 	mtk_ethdr_disable_vblank(ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0]);
 }
 
+const u32 *mtk_ovl_adaptor_get_formats(struct device *dev)
+{
+	return formats;
+}
+
+size_t mtk_ovl_adaptor_get_num_formats(struct device *dev)
+{
+	return ARRAY_SIZE(formats);
+}
+
 void mtk_ovl_adaptor_add_comp(struct device *dev, struct mtk_mutex *mutex)
 {
 	mtk_mutex_add_comp(mutex, DDP_COMPONENT_MDP_RDMA0);
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
index 1a0c4f7e352a..f114da4d36a9 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
@@ -410,6 +410,8 @@  static const struct mtk_ddp_comp_funcs ddp_ovl_adaptor = {
 	.disconnect = mtk_ovl_adaptor_disconnect,
 	.add = mtk_ovl_adaptor_add_comp,
 	.remove = mtk_ovl_adaptor_remove_comp,
+	.get_formats = mtk_ovl_adaptor_get_formats,
+	.get_num_formats = mtk_ovl_adaptor_get_num_formats,
 };
 
 static const char * const mtk_ddp_comp_stem[MTK_DDP_COMP_TYPE_MAX] = {