mirror of
https://github.com/team-infusion-developers/android_kernel_samsung_msm8976.git
synced 2024-09-21 20:04:01 +00:00
video: adf: add buffer padding quirk
Quirks specify common behaviors that vary slightly among devices, and which ADF must account for. The buffer padding quirk captures the way different devices fetch the last scanline in a buffer: some devices fetch an entire line (including padding to the pitch) while others only fetch up to the visible width. ADF's buffer size validation now takes this quirk into account. Change-Id: I828b13316e27621d8a9efd9d5fffa6ce12a525ff Signed-off-by: Greg Hackmann <ghackmann@google.com> Git-commit: adbe864576c5e5ac848d7e6009f760efdd00b44d Git-repo: https://android.googlesource.com/kernel/common.git Signed-off-by: Ian Maund <imaund@codeaurora.org>
This commit is contained in:
parent
0d91e39adf
commit
5b6417055c
|
@ -1073,6 +1073,7 @@ int adf_format_validate_yuv(struct adf_device *dev, struct adf_buffer *buf,
|
||||||
u32 width = buf->w / (i != 0 ? hsub : 1);
|
u32 width = buf->w / (i != 0 ? hsub : 1);
|
||||||
u32 height = buf->h / (i != 0 ? vsub : 1);
|
u32 height = buf->h / (i != 0 ? vsub : 1);
|
||||||
u8 cpp = adf_format_plane_cpp(buf->format, i);
|
u8 cpp = adf_format_plane_cpp(buf->format, i);
|
||||||
|
u32 last_line_size;
|
||||||
|
|
||||||
if (buf->pitch[i] < (u64) width * cpp) {
|
if (buf->pitch[i] < (u64) width * cpp) {
|
||||||
dev_err(&dev->base.dev, "plane %u pitch is shorter than buffer width (pitch = %u, width = %u, bpp = %u)\n",
|
dev_err(&dev->base.dev, "plane %u pitch is shorter than buffer width (pitch = %u, width = %u, bpp = %u)\n",
|
||||||
|
@ -1080,8 +1081,21 @@ int adf_format_validate_yuv(struct adf_device *dev, struct adf_buffer *buf,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((u64) height * buf->pitch[i] + buf->offset[i] >
|
switch (dev->ops->quirks.buffer_padding) {
|
||||||
buf->dma_bufs[i]->size) {
|
case ADF_BUFFER_PADDED_TO_PITCH:
|
||||||
|
last_line_size = buf->pitch[i];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ADF_BUFFER_UNPADDED:
|
||||||
|
last_line_size = width * cpp;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
BUG();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((u64) (height - 1) * buf->pitch[i] + last_line_size +
|
||||||
|
buf->offset[i] > buf->dma_bufs[i]->size) {
|
||||||
dev_err(&dev->base.dev, "plane %u buffer too small (height = %u, pitch = %u, offset = %u, size = %zu)\n",
|
dev_err(&dev->base.dev, "plane %u buffer too small (height = %u, pitch = %u, offset = %u, size = %zu)\n",
|
||||||
i, height, buf->pitch[i],
|
i, height, buf->pitch[i],
|
||||||
buf->offset[i], buf->dma_bufs[i]->size);
|
buf->offset[i], buf->dma_bufs[i]->size);
|
||||||
|
|
|
@ -192,11 +192,27 @@ struct adf_obj {
|
||||||
int minor;
|
int minor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct adf_device_quirks - common display device quirks
|
||||||
|
*
|
||||||
|
* @buffer_padding: whether the last scanline of a buffer extends to the
|
||||||
|
* buffer's pitch (@ADF_BUFFER_PADDED_TO_PITCH) or just to the visible
|
||||||
|
* width (@ADF_BUFFER_UNPADDED)
|
||||||
|
*/
|
||||||
|
struct adf_device_quirks {
|
||||||
|
/* optional, defaults to ADF_BUFFER_PADDED_TO_PITCH */
|
||||||
|
enum {
|
||||||
|
ADF_BUFFER_PADDED_TO_PITCH = 0,
|
||||||
|
ADF_BUFFER_UNPADDED = 1,
|
||||||
|
} buffer_padding;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct adf_device_ops - display device implementation ops
|
* struct adf_device_ops - display device implementation ops
|
||||||
*
|
*
|
||||||
* @owner: device's module
|
* @owner: device's module
|
||||||
* @base: common operations (see &struct adf_obj_ops)
|
* @base: common operations (see &struct adf_obj_ops)
|
||||||
|
* @quirks: device's quirks (see &struct adf_device_quirks)
|
||||||
*
|
*
|
||||||
* @attach: attach overlay engine @eng to interface @intf. Return 0 on success
|
* @attach: attach overlay engine @eng to interface @intf. Return 0 on success
|
||||||
* or error code (<0) on failure.
|
* or error code (<0) on failure.
|
||||||
|
@ -228,6 +244,8 @@ struct adf_device_ops {
|
||||||
/* required */
|
/* required */
|
||||||
struct module *owner;
|
struct module *owner;
|
||||||
const struct adf_obj_ops base;
|
const struct adf_obj_ops base;
|
||||||
|
/* optional */
|
||||||
|
const struct adf_device_quirks quirks;
|
||||||
|
|
||||||
/* optional */
|
/* optional */
|
||||||
int (*attach)(struct adf_device *dev, struct adf_overlay_engine *eng,
|
int (*attach)(struct adf_device *dev, struct adf_overlay_engine *eng,
|
||||||
|
|
Loading…
Reference in a new issue