Skip to content

Commit 451921e

Browse files
gcarlos64Thomas Zimmermann
authored andcommitted
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 <[email protected]> Reviewed-by: André Almeida <[email protected]> Signed-off-by: Thomas Zimmermann <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent f2f4559 commit 451921e

File tree

3 files changed

+5
-66
lines changed

3 files changed

+5
-66
lines changed

drivers/gpu/drm/drm_framebuffer.c

Lines changed: 4 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -151,24 +151,6 @@ int drm_mode_addfb_ioctl(struct drm_device *dev,
151151
return drm_mode_addfb(dev, data, file_priv);
152152
}
153153

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-
172154
static int framebuffer_check(struct drm_device *dev,
173155
const struct drm_mode_fb_cmd2 *r)
174156
{
@@ -196,8 +178,8 @@ static int framebuffer_check(struct drm_device *dev,
196178
info = drm_get_format_info(dev, r);
197179

198180
for (i = 0; i < info->num_planes; i++) {
199-
unsigned int width = fb_plane_width(r->width, info, i);
200-
unsigned int height = fb_plane_height(r->height, info, i);
181+
unsigned int width = drm_format_info_plane_width(info, r->width, i);
182+
unsigned int height = drm_format_info_plane_height(info, r->height, i);
201183
unsigned int block_size = info->char_per_block[i];
202184
u64 min_pitch = drm_format_info_min_pitch(info, i, width);
203185

@@ -1136,44 +1118,6 @@ void drm_framebuffer_remove(struct drm_framebuffer *fb)
11361118
}
11371119
EXPORT_SYMBOL(drm_framebuffer_remove);
11381120

1139-
/**
1140-
* drm_framebuffer_plane_width - width of the plane given the first plane
1141-
* @width: width of the first plane
1142-
* @fb: the framebuffer
1143-
* @plane: plane index
1144-
*
1145-
* Returns:
1146-
* The width of @plane, given that the width of the first plane is @width.
1147-
*/
1148-
int drm_framebuffer_plane_width(int width,
1149-
const struct drm_framebuffer *fb, int plane)
1150-
{
1151-
if (plane >= fb->format->num_planes)
1152-
return 0;
1153-
1154-
return fb_plane_width(width, fb->format, plane);
1155-
}
1156-
EXPORT_SYMBOL(drm_framebuffer_plane_width);
1157-
1158-
/**
1159-
* drm_framebuffer_plane_height - height of the plane given the first plane
1160-
* @height: height of the first plane
1161-
* @fb: the framebuffer
1162-
* @plane: plane index
1163-
*
1164-
* Returns:
1165-
* The height of @plane, given that the height of the first plane is @height.
1166-
*/
1167-
int drm_framebuffer_plane_height(int height,
1168-
const struct drm_framebuffer *fb, int plane)
1169-
{
1170-
if (plane >= fb->format->num_planes)
1171-
return 0;
1172-
1173-
return fb_plane_height(height, fb->format, plane);
1174-
}
1175-
EXPORT_SYMBOL(drm_framebuffer_plane_height);
1176-
11771121
void drm_framebuffer_print_info(struct drm_printer *p, unsigned int indent,
11781122
const struct drm_framebuffer *fb)
11791123
{
@@ -1189,8 +1133,8 @@ void drm_framebuffer_print_info(struct drm_printer *p, unsigned int indent,
11891133

11901134
for (i = 0; i < fb->format->num_planes; i++) {
11911135
drm_printf_indent(p, indent + 1, "size[%u]=%dx%d\n", i,
1192-
drm_framebuffer_plane_width(fb->width, fb, i),
1193-
drm_framebuffer_plane_height(fb->height, fb, i));
1136+
drm_format_info_plane_width(fb->format, fb->width, i),
1137+
drm_format_info_plane_height(fb->format, fb->height, i));
11941138
drm_printf_indent(p, indent + 1, "pitch[%u]=%u\n", i, fb->pitches[i]);
11951139
drm_printf_indent(p, indent + 1, "offset[%u]=%u\n", i, fb->offsets[i]);
11961140
drm_printf_indent(p, indent + 1, "obj[%u]:%s\n", i,

drivers/gpu/drm/i915/display/intel_fb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,7 @@ static int intel_fb_offset_to_xy(int *x, int *y,
11171117
return -EINVAL;
11181118
}
11191119

1120-
height = drm_framebuffer_plane_height(fb->height, fb, color_plane);
1120+
height = drm_format_info_plane_height(fb->format, fb->height, color_plane);
11211121
height = ALIGN(height, intel_tile_height(fb, color_plane));
11221122

11231123
/* Catch potential overflows early */

include/drm/drm_framebuffer.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,6 @@ static inline void drm_framebuffer_assign(struct drm_framebuffer **p,
292292
&fb->head != (&(dev)->mode_config.fb_list); \
293293
fb = list_next_entry(fb, head))
294294

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-
300295
/**
301296
* struct drm_afbc_framebuffer - a special afbc frame buffer object
302297
*

0 commit comments

Comments
 (0)