int pin_count;
const struct format *format;
struct plane planes[4];
+ /* lock for pinning (pin_count and planes.paddr) */
+ struct mutex lock;
};
static int omap_framebuffer_create_handle(struct drm_framebuffer *fb,
struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
int ret, i, n = drm_format_num_planes(fb->pixel_format);
+ mutex_lock(&omap_fb->lock);
+
if (omap_fb->pin_count > 0) {
omap_fb->pin_count++;
+ mutex_unlock(&omap_fb->lock);
return 0;
}
omap_fb->pin_count++;
+ mutex_unlock(&omap_fb->lock);
+
return 0;
fail:
plane->paddr = 0;
}
+ mutex_unlock(&omap_fb->lock);
+
return ret;
}
struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
int ret, i, n = drm_format_num_planes(fb->pixel_format);
+ mutex_lock(&omap_fb->lock);
+
omap_fb->pin_count--;
- if (omap_fb->pin_count > 0)
+ if (omap_fb->pin_count > 0) {
+ mutex_unlock(&omap_fb->lock);
return 0;
+ }
for (i = 0; i < n; i++) {
struct plane *plane = &omap_fb->planes[i];
plane->paddr = 0;
}
+ mutex_unlock(&omap_fb->lock);
+
return 0;
fail:
+ mutex_unlock(&omap_fb->lock);
return ret;
}
fb = &omap_fb->base;
omap_fb->format = format;
+ mutex_init(&omap_fb->lock);
for (i = 0; i < n; i++) {
struct plane *plane = &omap_fb->planes[i];