diff mbox

[6/6] drm: vc4: use crtc helper drm_crtc_from_index()

Message ID 1483961145-18453-7-git-send-email-shawnguo@kernel.org (mailing list archive)
State New, archived
Headers show

Commit Message

Shawn Guo Jan. 9, 2017, 11:25 a.m. UTC
From: Shawn Guo <shawn.guo@linaro.org>

Use drm_crtc_from_index() to find drm_crtc for given index, so that we
do not need to maintain a pointer array in struct vc4_dev.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Cc: Eric Anholt <eric@anholt.net>
---
 drivers/gpu/drm/vc4/vc4_crtc.c | 17 +++++++----------
 drivers/gpu/drm/vc4/vc4_drv.h  |  1 -
 2 files changed, 7 insertions(+), 11 deletions(-)

Comments

Sean Paul Jan. 18, 2017, 3:07 p.m. UTC | #1
On Mon, Jan 9, 2017 at 6:25 AM, Shawn Guo <shawnguo@kernel.org> wrote:
> From: Shawn Guo <shawn.guo@linaro.org>
>
> Use drm_crtc_from_index() to find drm_crtc for given index, so that we
> do not need to maintain a pointer array in struct vc4_dev.
>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> Cc: Eric Anholt <eric@anholt.net>


Applied to drm-misc-next

Thanks!

Sean

> ---
>  drivers/gpu/drm/vc4/vc4_crtc.c | 17 +++++++----------
>  drivers/gpu/drm/vc4/vc4_drv.h  |  1 -
>  2 files changed, 7 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c
> index a0fd3e66bc4b..75b708b36890 100644
> --- a/drivers/gpu/drm/vc4/vc4_crtc.c
> +++ b/drivers/gpu/drm/vc4/vc4_crtc.c
> @@ -156,7 +156,8 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
>                             const struct drm_display_mode *mode)
>  {
>         struct vc4_dev *vc4 = to_vc4_dev(dev);
> -       struct vc4_crtc *vc4_crtc = vc4->crtc[crtc_id];
> +       struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
> +       struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
>         u32 val;
>         int fifo_lines;
>         int vblank_lines;
> @@ -272,9 +273,7 @@ int vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
>                                   int *max_error, struct timeval *vblank_time,
>                                   unsigned flags)
>  {
> -       struct vc4_dev *vc4 = to_vc4_dev(dev);
> -       struct vc4_crtc *vc4_crtc = vc4->crtc[crtc_id];
> -       struct drm_crtc *crtc = &vc4_crtc->base;
> +       struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
>         struct drm_crtc_state *state = crtc->state;
>
>         /* Helper routine in DRM core does all the work: */
> @@ -652,8 +651,8 @@ static void vc4_crtc_atomic_flush(struct drm_crtc *crtc,
>
>  int vc4_enable_vblank(struct drm_device *dev, unsigned int crtc_id)
>  {
> -       struct vc4_dev *vc4 = to_vc4_dev(dev);
> -       struct vc4_crtc *vc4_crtc = vc4->crtc[crtc_id];
> +       struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
> +       struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
>
>         CRTC_WRITE(PV_INTEN, PV_INT_VFP_START);
>
> @@ -662,8 +661,8 @@ int vc4_enable_vblank(struct drm_device *dev, unsigned int crtc_id)
>
>  void vc4_disable_vblank(struct drm_device *dev, unsigned int crtc_id)
>  {
> -       struct vc4_dev *vc4 = to_vc4_dev(dev);
> -       struct vc4_crtc *vc4_crtc = vc4->crtc[crtc_id];
> +       struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
> +       struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
>
>         CRTC_WRITE(PV_INTEN, 0);
>  }
> @@ -937,7 +936,6 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data)
>  {
>         struct platform_device *pdev = to_platform_device(dev);
>         struct drm_device *drm = dev_get_drvdata(master);
> -       struct vc4_dev *vc4 = to_vc4_dev(drm);
>         struct vc4_crtc *vc4_crtc;
>         struct drm_crtc *crtc;
>         struct drm_plane *primary_plane, *cursor_plane, *destroy_plane, *temp;
> @@ -975,7 +973,6 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data)
>                                   &vc4_crtc_funcs, NULL);
>         drm_crtc_helper_add(crtc, &vc4_crtc_helper_funcs);
>         primary_plane->crtc = crtc;
> -       vc4->crtc[drm_crtc_index(crtc)] = vc4_crtc;
>         vc4_crtc->channel = vc4_crtc->data->hvs_channel;
>         drm_mode_crtc_set_gamma_size(crtc, ARRAY_SIZE(vc4_crtc->lut_r));
>
> diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
> index b5c4bb14d0d1..5d8486cbd574 100644
> --- a/drivers/gpu/drm/vc4/vc4_drv.h
> +++ b/drivers/gpu/drm/vc4/vc4_drv.h
> @@ -14,7 +14,6 @@ struct vc4_dev {
>
>         struct vc4_hdmi *hdmi;
>         struct vc4_hvs *hvs;
> -       struct vc4_crtc *crtc[3];
>         struct vc4_v3d *v3d;
>         struct vc4_dpi *dpi;
>         struct vc4_vec *vec;
> --
> 1.9.1
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c
index a0fd3e66bc4b..75b708b36890 100644
--- a/drivers/gpu/drm/vc4/vc4_crtc.c
+++ b/drivers/gpu/drm/vc4/vc4_crtc.c
@@ -156,7 +156,8 @@  int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 			    const struct drm_display_mode *mode)
 {
 	struct vc4_dev *vc4 = to_vc4_dev(dev);
-	struct vc4_crtc *vc4_crtc = vc4->crtc[crtc_id];
+	struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
+	struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
 	u32 val;
 	int fifo_lines;
 	int vblank_lines;
@@ -272,9 +273,7 @@  int vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
 				  int *max_error, struct timeval *vblank_time,
 				  unsigned flags)
 {
-	struct vc4_dev *vc4 = to_vc4_dev(dev);
-	struct vc4_crtc *vc4_crtc = vc4->crtc[crtc_id];
-	struct drm_crtc *crtc = &vc4_crtc->base;
+	struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
 	struct drm_crtc_state *state = crtc->state;
 
 	/* Helper routine in DRM core does all the work: */
@@ -652,8 +651,8 @@  static void vc4_crtc_atomic_flush(struct drm_crtc *crtc,
 
 int vc4_enable_vblank(struct drm_device *dev, unsigned int crtc_id)
 {
-	struct vc4_dev *vc4 = to_vc4_dev(dev);
-	struct vc4_crtc *vc4_crtc = vc4->crtc[crtc_id];
+	struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
+	struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
 
 	CRTC_WRITE(PV_INTEN, PV_INT_VFP_START);
 
@@ -662,8 +661,8 @@  int vc4_enable_vblank(struct drm_device *dev, unsigned int crtc_id)
 
 void vc4_disable_vblank(struct drm_device *dev, unsigned int crtc_id)
 {
-	struct vc4_dev *vc4 = to_vc4_dev(dev);
-	struct vc4_crtc *vc4_crtc = vc4->crtc[crtc_id];
+	struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
+	struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
 
 	CRTC_WRITE(PV_INTEN, 0);
 }
@@ -937,7 +936,6 @@  static int vc4_crtc_bind(struct device *dev, struct device *master, void *data)
 {
 	struct platform_device *pdev = to_platform_device(dev);
 	struct drm_device *drm = dev_get_drvdata(master);
-	struct vc4_dev *vc4 = to_vc4_dev(drm);
 	struct vc4_crtc *vc4_crtc;
 	struct drm_crtc *crtc;
 	struct drm_plane *primary_plane, *cursor_plane, *destroy_plane, *temp;
@@ -975,7 +973,6 @@  static int vc4_crtc_bind(struct device *dev, struct device *master, void *data)
 				  &vc4_crtc_funcs, NULL);
 	drm_crtc_helper_add(crtc, &vc4_crtc_helper_funcs);
 	primary_plane->crtc = crtc;
-	vc4->crtc[drm_crtc_index(crtc)] = vc4_crtc;
 	vc4_crtc->channel = vc4_crtc->data->hvs_channel;
 	drm_mode_crtc_set_gamma_size(crtc, ARRAY_SIZE(vc4_crtc->lut_r));
 
diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
index b5c4bb14d0d1..5d8486cbd574 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.h
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
@@ -14,7 +14,6 @@  struct vc4_dev {
 
 	struct vc4_hdmi *hdmi;
 	struct vc4_hvs *hvs;
-	struct vc4_crtc *crtc[3];
 	struct vc4_v3d *v3d;
 	struct vc4_dpi *dpi;
 	struct vc4_vec *vec;