summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorGreg Hackmann <ghackmann@google.com>2014-04-08 12:36:41 -0700
committerNitin Garg <nitin.garg@freescale.com>2014-04-21 22:35:45 -0500
commite5b48b2f7e27af52ce615226aac0d4c0223bb28a (patch)
tree431e1aff9de85fc4e4bdf81f9827dd35fd8018e8 /drivers
parent7f1f942004f29908f89842af58d5527e1d0005ca (diff)
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/video/adf/adf.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/video/adf/adf.c b/drivers/video/adf/adf.c
index 589baaa5fbcd..e6ef144136c2 100644
--- a/drivers/video/adf/adf.c
+++ b/drivers/video/adf/adf.c
@@ -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 height = buf->h / (i != 0 ? vsub : 1);
u8 cpp = adf_format_plane_cpp(buf->format, i);
+ u32 last_line_size;
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",
@@ -1080,8 +1081,21 @@ int adf_format_validate_yuv(struct adf_device *dev, struct adf_buffer *buf,
return -EINVAL;
}
- if ((u64) height * buf->pitch[i] + buf->offset[i] >
- buf->dma_bufs[i]->size) {
+ switch (dev->ops->quirks.buffer_padding) {
+ 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",
i, height, buf->pitch[i],
buf->offset[i], buf->dma_bufs[i]->size);