接前一篇文章:KWin、libdrm、DRM从上到下全过程 —— drmModeAddFBxxx(8)
上一回讲完了drm_internal_framebuffer_create函数中的framebuffer_check函数中的drm_get_format_info函数,本文继续讲解framebuffer_check函数中的余下步骤。为了便于理解,再次贴出framebuffer_check函数源码,在drivers/gpu/drm/drm_framebuffer.c中,代码如下:
- static int framebuffer_check(struct drm_device *dev,
- const struct drm_mode_fb_cmd2 *r)
- {
- const struct drm_format_info *info;
- int i;
-
- /* check if the format is supported at all */
- if (!__drm_format_info(r->pixel_format)) {
- drm_dbg_kms(dev, "bad framebuffer format %p4cc\n",
- &r->pixel_format);
- return -EINVAL;
- }
-
- if (r->width == 0) {
- drm_dbg_kms(dev, "bad framebuffer width %u\n", r->width);
- return -EINVAL;
- }
-
- if (r->height ==