mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2026-01-27 12:35:36 +01:00
LF-15180: media: imx-jpeg: Account for data_offset when getting image address
Applications may set data_offset when it refers to an output queue. So driver need to account for it when getting the start address of input image in the plane. Meanwhile data_offset is included in bytesused. So the data_offset should be subtracted from the payload of input image. Signed-off-by: Ming Qian <ming.qian@nxp.com> Reviewed-by: Zhou Peng <eagle.zhou@nxp.com> Acked-by: Jason Liu <jason.hui.liu@nxp.com>
This commit is contained in:
parent
1e18a7646b
commit
3b53d8b471
|
|
@ -599,6 +599,27 @@ static void _bswap16(u16 *a)
|
|||
*a = ((*a & 0x00FF) << 8) | ((*a & 0xFF00) >> 8);
|
||||
}
|
||||
|
||||
static dma_addr_t mxc_jpeg_get_plane_dma_addr(struct vb2_buffer *buf, unsigned int plane_no)
|
||||
{
|
||||
if (plane_no >= buf->num_planes)
|
||||
return 0;
|
||||
return vb2_dma_contig_plane_dma_addr(buf, plane_no) + buf->planes[plane_no].data_offset;
|
||||
}
|
||||
|
||||
static void *mxc_jpeg_get_plane_vaddr(struct vb2_buffer *buf, unsigned int plane_no)
|
||||
{
|
||||
if (plane_no >= buf->num_planes)
|
||||
return NULL;
|
||||
return vb2_plane_vaddr(buf, plane_no) + buf->planes[plane_no].data_offset;
|
||||
}
|
||||
|
||||
static unsigned long mxc_jpeg_get_plane_payload(struct vb2_buffer *buf, unsigned int plane_no)
|
||||
{
|
||||
if (plane_no >= buf->num_planes)
|
||||
return 0;
|
||||
return vb2_get_plane_payload(buf, plane_no) - buf->planes[plane_no].data_offset;
|
||||
}
|
||||
|
||||
static void print_mxc_buf(struct mxc_jpeg_dev *jpeg, struct vb2_buffer *buf,
|
||||
unsigned long len)
|
||||
{
|
||||
|
|
@ -611,11 +632,11 @@ static void print_mxc_buf(struct mxc_jpeg_dev *jpeg, struct vb2_buffer *buf,
|
|||
return;
|
||||
|
||||
for (plane_no = 0; plane_no < buf->num_planes; plane_no++) {
|
||||
payload = vb2_get_plane_payload(buf, plane_no);
|
||||
payload = mxc_jpeg_get_plane_payload(buf, plane_no);
|
||||
if (len == 0)
|
||||
len = payload;
|
||||
dma_addr = vb2_dma_contig_plane_dma_addr(buf, plane_no);
|
||||
vaddr = vb2_plane_vaddr(buf, plane_no);
|
||||
dma_addr = mxc_jpeg_get_plane_dma_addr(buf, plane_no);
|
||||
vaddr = mxc_jpeg_get_plane_vaddr(buf, plane_no);
|
||||
v4l2_dbg(3, debug, &jpeg->v4l2_dev,
|
||||
"plane %d (vaddr=%p dma_addr=%x payload=%ld):",
|
||||
plane_no, vaddr, dma_addr, payload);
|
||||
|
|
@ -713,16 +734,15 @@ static void mxc_jpeg_addrs(struct mxc_jpeg_desc *desc,
|
|||
struct mxc_jpeg_q_data *q_data;
|
||||
|
||||
q_data = mxc_jpeg_get_q_data(ctx, raw_buf->type);
|
||||
desc->buf_base0 = vb2_dma_contig_plane_dma_addr(raw_buf, 0);
|
||||
desc->buf_base0 = mxc_jpeg_get_plane_dma_addr(raw_buf, 0);
|
||||
desc->buf_base1 = 0;
|
||||
if (img_fmt == STM_CTRL_IMAGE_FORMAT(MXC_JPEG_YUV420)) {
|
||||
if (raw_buf->num_planes == 2)
|
||||
desc->buf_base1 = vb2_dma_contig_plane_dma_addr(raw_buf, 1);
|
||||
desc->buf_base1 = mxc_jpeg_get_plane_dma_addr(raw_buf, 1);
|
||||
else
|
||||
desc->buf_base1 = desc->buf_base0 + q_data->sizeimage[0];
|
||||
}
|
||||
desc->stm_bufbase = vb2_dma_contig_plane_dma_addr(jpeg_buf, 0) +
|
||||
offset;
|
||||
desc->stm_bufbase = mxc_jpeg_get_plane_dma_addr(jpeg_buf, 0) + offset;
|
||||
}
|
||||
|
||||
static bool mxc_jpeg_is_extended_sequential(const struct mxc_jpeg_fmt *fmt)
|
||||
|
|
@ -979,8 +999,8 @@ static irqreturn_t mxc_jpeg_dec_irq(int irq, void *priv)
|
|||
vb2_set_plane_payload(&dst_buf->vb2_buf, 1, payload);
|
||||
}
|
||||
dev_dbg(dev, "Decoding finished, payload size: %ld + %ld\n",
|
||||
vb2_get_plane_payload(&dst_buf->vb2_buf, 0),
|
||||
vb2_get_plane_payload(&dst_buf->vb2_buf, 1));
|
||||
mxc_jpeg_get_plane_payload(&dst_buf->vb2_buf, 0),
|
||||
mxc_jpeg_get_plane_payload(&dst_buf->vb2_buf, 1));
|
||||
}
|
||||
|
||||
/* short preview of the results */
|
||||
|
|
@ -1839,8 +1859,8 @@ static int mxc_jpeg_parse(struct mxc_jpeg_ctx *ctx, struct vb2_buffer *vb)
|
|||
struct mxc_jpeg_sof *psof = NULL;
|
||||
struct mxc_jpeg_sos *psos = NULL;
|
||||
struct mxc_jpeg_src_buf *jpeg_src_buf = vb2_to_mxc_buf(vb);
|
||||
u8 *src_addr = (u8 *)vb2_plane_vaddr(vb, 0);
|
||||
u32 size = vb2_get_plane_payload(vb, 0);
|
||||
u8 *src_addr = (u8 *)mxc_jpeg_get_plane_vaddr(vb, 0);
|
||||
u32 size = mxc_jpeg_get_plane_payload(vb, 0);
|
||||
int ret;
|
||||
|
||||
memset(&header, 0, sizeof(header));
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user