Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm: Replace drm_framebuffer plane size functions with its equivalents

The functions drm_framebuffer_plane_{width,height} and
fb_plane_{width,height} do exactly the same job of its
equivalents drm_format_info_plane_{width,height} from drm_fourcc.

The only reason to have these functions on drm_framebuffer
would be if they would added a abstraction layer to call it just
passing a drm_framebuffer pointer and the desired plane index,
which is not the case, where these functions actually implements
just part of it. In the actual implementation, every call to both
drm_framebuffer_plane_{width,height} and fb_plane_{width,height} should
pass some drm_framebuffer attribute, which is the same as calling the
drm_format_info_plane_{width,height} functions.

The drm_format_info_pane_{width,height} functions are much more
consistent in both its implementation and its location on code. The
kind of calculation that they do is intrinsically derivated from the
drm_format_info struct and has not to do with drm_framebuffer, except
by the potential motivation described above, which is still not a good
justification to have drm_framebuffer functions to calculate it.

So, replace each drm_framebuffer_plane_{width,height} and
fb_plane_{width,height} call to drm_format_info_plane_{width,height}
and remove them.

Signed-off-by: Carlos Eduardo Gallo Filho <gcarlos@disroot.org>
Reviewed-by: André Almeida <andrealmeid@igalia.com>
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20230926141519.9315-3-gcarlos@disroot.org

authored by

Carlos Eduardo Gallo Filho and committed by
Thomas Zimmermann
451921e7 f2f45598

+5 -66
+4 -60
drivers/gpu/drm/drm_framebuffer.c
··· 151 151 return drm_mode_addfb(dev, data, file_priv); 152 152 } 153 153 154 - static int fb_plane_width(int width, 155 - const struct drm_format_info *format, int plane) 156 - { 157 - if (plane == 0) 158 - return width; 159 - 160 - return DIV_ROUND_UP(width, format->hsub); 161 - } 162 - 163 - static int fb_plane_height(int height, 164 - const struct drm_format_info *format, int plane) 165 - { 166 - if (plane == 0) 167 - return height; 168 - 169 - return DIV_ROUND_UP(height, format->vsub); 170 - } 171 - 172 154 static int framebuffer_check(struct drm_device *dev, 173 155 const struct drm_mode_fb_cmd2 *r) 174 156 { ··· 178 196 info = drm_get_format_info(dev, r); 179 197 180 198 for (i = 0; i < info->num_planes; i++) { 181 - unsigned int width = fb_plane_width(r->width, info, i); 182 - unsigned int height = fb_plane_height(r->height, info, i); 199 + unsigned int width = drm_format_info_plane_width(info, r->width, i); 200 + unsigned int height = drm_format_info_plane_height(info, r->height, i); 183 201 unsigned int block_size = info->char_per_block[i]; 184 202 u64 min_pitch = drm_format_info_min_pitch(info, i, width); 185 203 ··· 1118 1136 } 1119 1137 EXPORT_SYMBOL(drm_framebuffer_remove); 1120 1138 1121 - /** 1122 - * drm_framebuffer_plane_width - width of the plane given the first plane 1123 - * @width: width of the first plane 1124 - * @fb: the framebuffer 1125 - * @plane: plane index 1126 - * 1127 - * Returns: 1128 - * The width of @plane, given that the width of the first plane is @width. 1129 - */ 1130 - int drm_framebuffer_plane_width(int width, 1131 - const struct drm_framebuffer *fb, int plane) 1132 - { 1133 - if (plane >= fb->format->num_planes) 1134 - return 0; 1135 - 1136 - return fb_plane_width(width, fb->format, plane); 1137 - } 1138 - EXPORT_SYMBOL(drm_framebuffer_plane_width); 1139 - 1140 - /** 1141 - * drm_framebuffer_plane_height - height of the plane given the first plane 1142 - * @height: height of the first plane 1143 - * @fb: the framebuffer 1144 - * @plane: plane index 1145 - * 1146 - * Returns: 1147 - * The height of @plane, given that the height of the first plane is @height. 1148 - */ 1149 - int drm_framebuffer_plane_height(int height, 1150 - const struct drm_framebuffer *fb, int plane) 1151 - { 1152 - if (plane >= fb->format->num_planes) 1153 - return 0; 1154 - 1155 - return fb_plane_height(height, fb->format, plane); 1156 - } 1157 - EXPORT_SYMBOL(drm_framebuffer_plane_height); 1158 - 1159 1139 void drm_framebuffer_print_info(struct drm_printer *p, unsigned int indent, 1160 1140 const struct drm_framebuffer *fb) 1161 1141 { ··· 1133 1189 1134 1190 for (i = 0; i < fb->format->num_planes; i++) { 1135 1191 drm_printf_indent(p, indent + 1, "size[%u]=%dx%d\n", i, 1136 - drm_framebuffer_plane_width(fb->width, fb, i), 1137 - drm_framebuffer_plane_height(fb->height, fb, i)); 1192 + drm_format_info_plane_width(fb->format, fb->width, i), 1193 + drm_format_info_plane_height(fb->format, fb->height, i)); 1138 1194 drm_printf_indent(p, indent + 1, "pitch[%u]=%u\n", i, fb->pitches[i]); 1139 1195 drm_printf_indent(p, indent + 1, "offset[%u]=%u\n", i, fb->offsets[i]); 1140 1196 drm_printf_indent(p, indent + 1, "obj[%u]:%s\n", i,
+1 -1
drivers/gpu/drm/i915/display/intel_fb.c
··· 1117 1117 return -EINVAL; 1118 1118 } 1119 1119 1120 - height = drm_framebuffer_plane_height(fb->height, fb, color_plane); 1120 + height = drm_format_info_plane_height(fb->format, fb->height, color_plane); 1121 1121 height = ALIGN(height, intel_tile_height(fb, color_plane)); 1122 1122 1123 1123 /* Catch potential overflows early */
-5
include/drm/drm_framebuffer.h
··· 292 292 &fb->head != (&(dev)->mode_config.fb_list); \ 293 293 fb = list_next_entry(fb, head)) 294 294 295 - int drm_framebuffer_plane_width(int width, 296 - const struct drm_framebuffer *fb, int plane); 297 - int drm_framebuffer_plane_height(int height, 298 - const struct drm_framebuffer *fb, int plane); 299 - 300 295 /** 301 296 * struct drm_afbc_framebuffer - a special afbc frame buffer object 302 297 *