* [PATCH] SOLO6x10: Fix video headers on certain hardware.
@ 2013-09-12 12:43 Krzysztof Hałasa
2013-11-05 22:11 ` Ismael Luceno
0 siblings, 1 reply; 2+ messages in thread
From: Krzysztof Hałasa @ 2013-09-12 12:43 UTC (permalink / raw)
To: linux-media; +Cc: Hans Verkuil, ismael.luceno
On certain platforms a sequence of dma_map_sg() and dma_unmap_sg()
discards data previously stored in the buffers. Build video headers
only after the DMA is completed.
Signed-off-by: Krzysztof Hałasa <khalasa@piap.pl>
diff --git a/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c b/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c
index e501287..7a2fd98 100644
--- a/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c
+++ b/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c
@@ -472,14 +472,11 @@ static int solo_fill_jpeg(struct solo_enc_dev *solo_enc,
if (vb2_plane_size(vb, 0) < vop_jpeg_size(vh) + solo_enc->jpeg_len)
return -EIO;
- sg_copy_from_buffer(vbuf->sglist, vbuf->num_pages,
- solo_enc->jpeg_header,
- solo_enc->jpeg_len);
-
frame_size = (vop_jpeg_size(vh) + solo_enc->jpeg_len + (DMA_ALIGN - 1))
& ~(DMA_ALIGN - 1);
vb2_set_plane_payload(vb, 0, vop_jpeg_size(vh) + solo_enc->jpeg_len);
+ /* may discard all previous data in vbuf->sglist */
dma_map_sg(&solo_dev->pdev->dev, vbuf->sglist, vbuf->num_pages,
DMA_FROM_DEVICE);
ret = solo_send_desc(solo_enc, solo_enc->jpeg_len, vbuf,
@@ -488,6 +485,11 @@ static int solo_fill_jpeg(struct solo_enc_dev *solo_enc,
SOLO_JPEG_EXT_SIZE(solo_dev));
dma_unmap_sg(&solo_dev->pdev->dev, vbuf->sglist, vbuf->num_pages,
DMA_FROM_DEVICE);
+
+ /* add the header only after dma_unmap_sg() */
+ sg_copy_from_buffer(vbuf->sglist, vbuf->num_pages,
+ solo_enc->jpeg_header, solo_enc->jpeg_len);
+
return ret;
}
@@ -505,12 +507,7 @@ static int solo_fill_mpeg(struct solo_enc_dev *solo_enc,
/* If this is a key frame, add extra header */
if (!vop_type(vh)) {
- sg_copy_from_buffer(vbuf->sglist, vbuf->num_pages,
- solo_enc->vop,
- solo_enc->vop_len);
-
skip = solo_enc->vop_len;
-
vb->v4l2_buf.flags |= V4L2_BUF_FLAG_KEYFRAME;
vb2_set_plane_payload(vb, 0, vop_mpeg_size(vh) + solo_enc->vop_len);
} else {
@@ -524,6 +521,7 @@ static int solo_fill_mpeg(struct solo_enc_dev *solo_enc,
frame_size = (vop_mpeg_size(vh) + skip + (DMA_ALIGN - 1))
& ~(DMA_ALIGN - 1);
+ /* may discard all previous data in vbuf->sglist */
dma_map_sg(&solo_dev->pdev->dev, vbuf->sglist, vbuf->num_pages,
DMA_FROM_DEVICE);
ret = solo_send_desc(solo_enc, skip, vbuf, frame_off, frame_size,
@@ -531,6 +529,11 @@ static int solo_fill_mpeg(struct solo_enc_dev *solo_enc,
SOLO_MP4E_EXT_SIZE(solo_dev));
dma_unmap_sg(&solo_dev->pdev->dev, vbuf->sglist, vbuf->num_pages,
DMA_FROM_DEVICE);
+
+ /* add the header only after dma_unmap_sg() */
+ if (!vop_type(vh))
+ sg_copy_from_buffer(vbuf->sglist, vbuf->num_pages,
+ solo_enc->vop, solo_enc->vop_len);
return ret;
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] SOLO6x10: Fix video headers on certain hardware.
2013-09-12 12:43 [PATCH] SOLO6x10: Fix video headers on certain hardware Krzysztof Hałasa
@ 2013-11-05 22:11 ` Ismael Luceno
0 siblings, 0 replies; 2+ messages in thread
From: Ismael Luceno @ 2013-11-05 22:11 UTC (permalink / raw)
To: Krzysztof Hałasa; +Cc: linux-media, Hans Verkuil
[-- Attachment #1: Type: text/plain, Size: 391 bytes --]
On Thu, 12 Sep 2013 14:43:34 +0200
khalasa@piap.pl (Krzysztof Hałasa) wrote:
> On certain platforms a sequence of dma_map_sg() and dma_unmap_sg()
> discards data previously stored in the buffers. Build video headers
> only after the DMA is completed.
>
> Signed-off-by: Krzysztof Hałasa <khalasa@piap.pl>
>
Acked-by: Ismael Luceno <ismael.luceno@corp.bluecherry.net>
<...>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-11-05 22:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-12 12:43 [PATCH] SOLO6x10: Fix video headers on certain hardware Krzysztof Hałasa
2013-11-05 22:11 ` Ismael Luceno
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).