@@ -124,7 +124,12 @@ komeda_fb_none_afbc_size_check(struct komeda_dev *mdev,
return -EINVAL;
}
- min_size = komeda_fb_get_pixel_addr(kfb, 0, fb->height, i)
+ min_size = komeda_fb_get_pixel_addr_nofb(info,
+ mode_cmd->modifier[0],
+ mode_cmd->pitches,
+ mode_cmd->offsets,
+ obj,
+ 0, mode_cmd->height, i)
- to_drm_gem_cma_obj(obj)->paddr;
if (obj->size < min_size) {
DRM_DEBUG_KMS("The fb->obj[%d] size: 0x%zx lower than the minimum requirement: 0x%llx.\n",
@@ -238,12 +243,56 @@ int komeda_fb_check_src_coords(const struct komeda_fb *kfb,
return 0;
}
+dma_addr_t
+komeda_fb_get_pixel_addr_impl(const struct drm_format_info *format,
+ u64 modifier,
+ const unsigned int *pitches,
+ const unsigned int *offsets,
+ const struct drm_gem_cma_object *obj,
+ int x, int y, int plane)
+{
+ u32 offset, plane_x, plane_y, block_w, block_sz;
+
+ offset = offsets[plane];
+ if (modifier) {
+ block_w = drm_format_info_block_width(format, plane);
+ block_sz = format->char_per_block[plane];
+ plane_x = x / (plane ? format->hsub : 1);
+ plane_y = y / (plane ? format->vsub : 1);
+
+ offset += (plane_x / block_w) * block_sz
+ + plane_y * pitches[plane];
+ }
+
+ return obj->paddr + offset;
+}
+
+dma_addr_t
+komeda_fb_get_pixel_addr_nofb(const struct drm_format_info *format,
+ u64 modifier,
+ const unsigned int *pitches,
+ const unsigned int *offsets,
+ struct drm_gem_object *obj,
+ int x, int y, int plane)
+{
+ const struct drm_gem_cma_object *cma_obj;
+
+ if (plane >= format->num_planes) {
+ DRM_DEBUG_KMS("Out of max plane num.\n");
+ return -EINVAL;
+ }
+
+ cma_obj = to_drm_gem_cma_obj(obj);
+
+ return komeda_fb_get_pixel_addr_impl(format, modifier, pitches, offsets,
+ cma_obj, x, y, plane);
+}
+
dma_addr_t
komeda_fb_get_pixel_addr(struct komeda_fb *kfb, int x, int y, int plane)
{
struct drm_framebuffer *fb = &kfb->base;
const struct drm_gem_cma_object *obj;
- u32 offset, plane_x, plane_y, block_w, block_sz;
if (plane >= fb->format->num_planes) {
DRM_DEBUG_KMS("Out of max plane num.\n");
@@ -252,18 +301,9 @@ komeda_fb_get_pixel_addr(struct komeda_fb *kfb, int x, int y, int plane)
obj = drm_fb_cma_get_gem_obj(fb, plane);
- offset = fb->offsets[plane];
- if (!fb->modifier) {
- block_w = drm_format_info_block_width(fb->format, plane);
- block_sz = fb->format->char_per_block[plane];
- plane_x = x / (plane ? fb->format->hsub : 1);
- plane_y = y / (plane ? fb->format->vsub : 1);
-
- offset += (plane_x / block_w) * block_sz
- + plane_y * fb->pitches[plane];
- }
-
- return obj->paddr + offset;
+ return komeda_fb_get_pixel_addr_impl(fb->format, fb->modifier,
+ fb->pitches, fb->offsets,
+ obj, x, y, plane);
}
/* if the fb can be supported by a specific layer */
@@ -42,6 +42,13 @@ int komeda_fb_check_src_coords(const struct komeda_fb *kfb,
u32 src_x, u32 src_y, u32 src_w, u32 src_h);
dma_addr_t
komeda_fb_get_pixel_addr(struct komeda_fb *kfb, int x, int y, int plane);
+dma_addr_t
+komeda_fb_get_pixel_addr_nofb(const struct drm_format_info *format,
+ u64 modifier,
+ const unsigned int *pitches,
+ const unsigned int *offsets,
+ struct drm_gem_object *obj,
+ int x, int y, int plane);
bool komeda_fb_is_layer_supported(struct komeda_fb *kfb, u32 layer_type,
u32 rot);
Add a variant of the function which doesn't need neither struct drm_framebuffer nor container_of it. Maintain current interface for existing users. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com> --- .../arm/display/komeda/komeda_framebuffer.c | 68 +++++++++++++++---- .../arm/display/komeda/komeda_framebuffer.h | 7 ++ 2 files changed, 61 insertions(+), 14 deletions(-)