]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
drm: Replace drm_format_num_planes() with fb->format->num_planes
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 14 Dec 2016 21:30:22 +0000 (23:30 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Thu, 15 Dec 2016 12:55:31 +0000 (14:55 +0200)
Replace drm_format_num_planes(fb->pixel_format) with just
fb->format->num_planes. Avoids the expensive format info lookup.

@@
struct drm_framebuffer *a;
struct drm_framebuffer b;
@@
(
- drm_format_num_planes(a->pixel_format)
+ a->format->num_planes
|
- drm_format_num_planes(b.pixel_format)
+ b.format->num_planes
)

@@
struct drm_plane_state *a;
struct drm_plane_state b;
@@
(
- drm_format_num_planes(a->fb->pixel_format)
+ a->fb->format->num_planes
|
- drm_format_num_planes(b.fb->pixel_format)
+ b.fb->format->num_planes
)

@@
struct drm_framebuffer *a;
identifier T;
@@
  T = a->pixel_format
<+...
- drm_format_num_planes(T)
+ a->format->num_planes
...+>

@@
struct drm_framebuffer b;
identifier T;
@@
  T = b.pixel_format
<+...
- drm_format_num_planes(T)
+ b.format->num_planes
...+>

v2: Rerun spatch due to code changes

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1481751022-18015-1-git-send-email-ville.syrjala@linux.intel.com
13 files changed:
drivers/gpu/drm/arm/malidp_planes.c
drivers/gpu/drm/armada/armada_crtc.c
drivers/gpu/drm/armada/armada_overlay.c
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.c
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
drivers/gpu/drm/drm_atomic.c
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
drivers/gpu/drm/msm/msm_fb.c
drivers/gpu/drm/omapdrm/omap_fb.c
drivers/gpu/drm/tegra/dc.c
drivers/gpu/drm/tegra/fb.c
drivers/gpu/drm/vc4/vc4_plane.c

index ee7f7663a307d7783a899c35188bd8a85ef5bea0..533ee2fa64be7e003ab80b659d54983ed4374c3d 100644 (file)
@@ -116,7 +116,7 @@ static int malidp_de_plane_check(struct drm_plane *plane,
        if (ms->format == MALIDP_INVALID_FORMAT_ID)
                return -EINVAL;
 
-       ms->n_planes = drm_format_num_planes(fb->pixel_format);
+       ms->n_planes = fb->format->num_planes;
        for (i = 0; i < ms->n_planes; i++) {
                if (!malidp_hw_pitch_valid(mp->hwdev, fb->pitches[i])) {
                        DRM_DEBUG_KMS("Invalid pitch %u for plane %d\n",
index 95cb3966b2ca9ba9eb437cbeaa3d89c5f0f50b87..2e1c63569c7289e1a29be6f9543082ff959ca4bd 100644 (file)
@@ -170,7 +170,7 @@ void armada_drm_plane_calc_addrs(u32 *addrs, struct drm_framebuffer *fb,
 {
        u32 addr = drm_fb_obj(fb)->dev_addr;
        u32 pixel_format = fb->pixel_format;
-       int num_planes = drm_format_num_planes(pixel_format);
+       int num_planes = fb->format->num_planes;
        int i;
 
        if (num_planes > 3)
index 6743615232f5c6b4da32dd4296c01f9966ebf756..a0883a1b338722ec789e3b4f951d3aff8657e1c8 100644 (file)
@@ -188,7 +188,7 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
 
                pixel_format = fb->pixel_format;
                hsub = drm_format_horz_chroma_subsampling(pixel_format);
-               num_planes = drm_format_num_planes(pixel_format);
+               num_planes = fb->format->num_planes;
 
                /*
                 * Annoyingly, shifting a YUYV-format image by one pixel
index 377e43cea9ddd1a489b29db56d70ae873d3f244d..63dfdbf34f80219e0309e0de23de004521b9de77 100644 (file)
@@ -446,7 +446,7 @@ void atmel_hlcdc_layer_update_set_fb(struct atmel_hlcdc_layer *layer,
                return;
 
        if (fb)
-               nplanes = drm_format_num_planes(fb->pixel_format);
+               nplanes = fb->format->num_planes;
 
        if (nplanes > layer->max_planes)
                return;
index 246ed1e33d8ac61d5a8a1f7b472607970efe12d8..f97ae75f9e63ffb6c86e0fd6199e77633c643c84 100644 (file)
@@ -621,7 +621,7 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
        state->src_w >>= 16;
        state->src_h >>= 16;
 
-       state->nplanes = drm_format_num_planes(fb->pixel_format);
+       state->nplanes = fb->format->num_planes;
        if (state->nplanes > ATMEL_HLCDC_MAX_PLANES)
                return -EINVAL;
 
index 60697482b94c8136ea2720dbf3b9f81c94e1d823..62f0f57728e1399372a11720663e069215792067 100644 (file)
@@ -960,7 +960,7 @@ static void drm_atomic_plane_print_state(struct drm_printer *p,
        drm_printf(p, "\tfb=%u\n", state->fb ? state->fb->base.id : 0);
        if (state->fb) {
                struct drm_framebuffer *fb = state->fb;
-               int i, n = drm_format_num_planes(fb->pixel_format);
+               int i, n = fb->format->num_planes;
                struct drm_format_name_buf format_name;
 
                drm_printf(p, "\t\tformat=%s\n",
index a760814ec974ea86e8f4fbd86b3254b2a45d76af..8e3ad9afbe3018883b3a3debf4857fc1dc841a42 100644 (file)
@@ -2497,7 +2497,7 @@ intel_fill_fb_info(struct drm_i915_private *dev_priv,
        u32 gtt_offset_rotated = 0;
        unsigned int max_size = 0;
        uint32_t format = fb->pixel_format;
-       int i, num_planes = drm_format_num_planes(format);
+       int i, num_planes = fb->format->num_planes;
        unsigned int tile_size = intel_tile_size(dev_priv);
 
        for (i = 0; i < num_planes; i++) {
index c099da7bc212d52f9bdf2d42f50da98e359cf53f..75247ea4335b5963567adf5c652bd9e45bc68639 100644 (file)
@@ -699,7 +699,7 @@ static int mdp5_plane_mode_set(struct drm_plane *plane,
        unsigned long flags;
        int ret;
 
-       nplanes = drm_format_num_planes(fb->pixel_format);
+       nplanes = fb->format->num_planes;
 
        /* bad formats should already be rejected: */
        if (WARN_ON(nplanes > pipe2nclients(pipe)))
index ccefd6a30f37027bfdfd7eac2a9477e5180ab132..0649863d7fd7b42ceac279036cad5ae80e448359 100644 (file)
@@ -41,7 +41,7 @@ static int msm_framebuffer_create_handle(struct drm_framebuffer *fb,
 static void msm_framebuffer_destroy(struct drm_framebuffer *fb)
 {
        struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
-       int i, n = drm_format_num_planes(fb->pixel_format);
+       int i, n = fb->format->num_planes;
 
        DBG("destroy: FB ID: %d (%p)", fb->base.id, fb);
 
@@ -65,7 +65,7 @@ static const struct drm_framebuffer_funcs msm_framebuffer_funcs = {
 void msm_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m)
 {
        struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
-       int i, n = drm_format_num_planes(fb->pixel_format);
+       int i, n = fb->format->num_planes;
 
        seq_printf(m, "fb: %dx%d@%4.4s (%2d, ID:%d)\n",
                        fb->width, fb->height, (char *)&fb->pixel_format,
@@ -87,7 +87,7 @@ void msm_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m)
 int msm_framebuffer_prepare(struct drm_framebuffer *fb, int id)
 {
        struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
-       int ret, i, n = drm_format_num_planes(fb->pixel_format);
+       int ret, i, n = fb->format->num_planes;
        uint64_t iova;
 
        for (i = 0; i < n; i++) {
@@ -103,7 +103,7 @@ int msm_framebuffer_prepare(struct drm_framebuffer *fb, int id)
 void msm_framebuffer_cleanup(struct drm_framebuffer *fb, int id)
 {
        struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
-       int i, n = drm_format_num_planes(fb->pixel_format);
+       int i, n = fb->format->num_planes;
 
        for (i = 0; i < n; i++)
                msm_gem_put_iova(msm_fb->planes[i], id);
index 9875c99be009ada880e1cb15ad71174db16ee984..c6ef457b9fca08676a588eccb97a6b749455b605 100644 (file)
@@ -107,7 +107,7 @@ static int omap_framebuffer_create_handle(struct drm_framebuffer *fb,
 static void omap_framebuffer_destroy(struct drm_framebuffer *fb)
 {
        struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
-       int i, n = drm_format_num_planes(fb->pixel_format);
+       int i, n = fb->format->num_planes;
 
        DBG("destroy: FB ID: %d (%p)", fb->base.id, fb);
 
@@ -252,7 +252,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
 int omap_framebuffer_pin(struct drm_framebuffer *fb)
 {
        struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
-       int ret, i, n = drm_format_num_planes(fb->pixel_format);
+       int ret, i, n = fb->format->num_planes;
 
        mutex_lock(&omap_fb->lock);
 
@@ -292,7 +292,7 @@ fail:
 void omap_framebuffer_unpin(struct drm_framebuffer *fb)
 {
        struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
-       int i, n = drm_format_num_planes(fb->pixel_format);
+       int i, n = fb->format->num_planes;
 
        mutex_lock(&omap_fb->lock);
 
@@ -343,7 +343,7 @@ struct drm_connector *omap_framebuffer_get_next_connector(
 void omap_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m)
 {
        struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
-       int i, n = drm_format_num_planes(fb->pixel_format);
+       int i, n = fb->format->num_planes;
 
        seq_printf(m, "fb: %dx%d@%4.4s\n", fb->width, fb->height,
                        (char *)&fb->pixel_format);
index 4010d69cbd08404714fe92df3a61ee1a2f3d3bfb..b60c306190e972d1113f5d084a0c4970bce847fa 100644 (file)
@@ -531,7 +531,7 @@ static int tegra_plane_atomic_check(struct drm_plane *plane,
         * error out if the user tries to display a framebuffer with such a
         * configuration.
         */
-       if (drm_format_num_planes(state->fb->pixel_format) > 2) {
+       if (state->fb->format->num_planes > 2) {
                if (state->fb->pitches[2] != state->fb->pitches[1]) {
                        DRM_ERROR("unsupported UV-plane configuration\n");
                        return -EINVAL;
@@ -576,7 +576,7 @@ static void tegra_plane_atomic_update(struct drm_plane *plane,
        window.format = state->format;
        window.swap = state->swap;
 
-       for (i = 0; i < drm_format_num_planes(fb->pixel_format); i++) {
+       for (i = 0; i < fb->format->num_planes; i++) {
                struct tegra_bo *bo = tegra_fb_get_plane(fb, i);
 
                window.base[i] = bo->paddr + fb->offsets[i];
index a0096493f51cb2e33b9675f97140524593085521..8a4aea211e94404b18ce5d781ca290fe63191e47 100644 (file)
@@ -32,7 +32,7 @@ struct tegra_bo *tegra_fb_get_plane(struct drm_framebuffer *framebuffer,
 {
        struct tegra_fb *fb = to_tegra_fb(framebuffer);
 
-       if (index >= drm_format_num_planes(framebuffer->pixel_format))
+       if (index >= framebuffer->format->num_planes)
                return NULL;
 
        return fb->planes[index];
index 881bf489478b01b34e9e4df6013fe608c42215ee..a7fb581c7c55e8b63faba359cf4bfb58d9b160a2 100644 (file)
@@ -296,7 +296,7 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state)
        struct drm_gem_cma_object *bo = drm_fb_cma_get_gem_obj(fb, 0);
        u32 subpixel_src_mask = (1 << 16) - 1;
        u32 format = fb->pixel_format;
-       int num_planes = drm_format_num_planes(format);
+       int num_planes = fb->format->num_planes;
        u32 h_subsample = 1;
        u32 v_subsample = 1;
        int i;