Commit 31391359 authored by Mikhail Karpenko's avatar Mikhail Karpenko

Insert app15 marker before header, fix offset error in circbuf

parent e33c95a7
...@@ -745,6 +745,17 @@ static void align_frame(struct device *dev, struct elphel_ahci_priv *dpriv) ...@@ -745,6 +745,17 @@ static void align_frame(struct device *dev, struct elphel_ahci_priv *dpriv)
vectshrink(&chunks[CHUNK_EXIF], chunks[CHUNK_EXIF].iov_len); vectshrink(&chunks[CHUNK_EXIF], chunks[CHUNK_EXIF].iov_len);
} }
/* align common buffer to ALIGNMENT boundary, APP15 marker should be placed before header data */
data_len = cbuff->iov_len + chunks[CHUNK_HEADER].iov_len;
len = align_bytes_num(data_len, ALIGNMENT_SIZE);
if (len < JPEG_MARKER_LEN + JPEG_SIZE_LEN && len != 0) {
/* the number of bytes needed for alignment is less than the length of the marker itself, increase the number of stuffing bytes */
len += ALIGNMENT_SIZE;
}
dev_dbg(dev, "total number of stuffing bytes in APP15 marker: %u\n", len);
app15[3] = len - JPEG_MARKER_LEN;
vectcpy(cbuff, app15, len);
/* copy JPEG header */ /* copy JPEG header */
len = chunks[CHUNK_HEADER].iov_len; len = chunks[CHUNK_HEADER].iov_len;
printk(KERN_DEBUG ">>> copy %u bytes from HEADER to common buffer\n", len); printk(KERN_DEBUG ">>> copy %u bytes from HEADER to common buffer\n", len);
...@@ -814,16 +825,6 @@ static void align_frame(struct device *dev, struct elphel_ahci_priv *dpriv) ...@@ -814,16 +825,6 @@ static void align_frame(struct device *dev, struct elphel_ahci_priv *dpriv)
return; return;
} }
/* align common buffer to ALIGNMENT boundary */
len = align_bytes_num(cbuff->iov_len, ALIGNMENT_SIZE);
if (len < JPEG_MARKER_LEN + JPEG_SIZE_LEN && len != 0) {
/* the number of bytes needed for alignment is less than the length of the marker itself, increase the number of stuffing bytes */
len += ALIGNMENT_SIZE;
}
dev_dbg(dev, "total number of stuffing bytes in APP15 marker: %u\n", len);
app15[3] = len - JPEG_MARKER_LEN;
vectcpy(cbuff, app15, len);
/* align frame to sector size boundary; total size could have changed by the moment - recalculate */ /* align frame to sector size boundary; total size could have changed by the moment - recalculate */
total_sz = get_size_from(chunks, 0, 0, INCLUDE_REM); total_sz = get_size_from(chunks, 0, 0, INCLUDE_REM);
len = total_sz % PHY_BLOCK_SIZE; len = total_sz % PHY_BLOCK_SIZE;
...@@ -1259,15 +1260,16 @@ static ssize_t rawdev_write(struct device *dev, ///< ...@@ -1259,15 +1260,16 @@ static ssize_t rawdev_write(struct device *dev, ///<
rcvd = exif_get_data(fdata.sensor_port, fdata.meta_index, buffs->exif_buff.iov_base, buffs->exif_buff.iov_len); rcvd = exif_get_data(fdata.sensor_port, fdata.meta_index, buffs->exif_buff.iov_base, buffs->exif_buff.iov_len);
// rcvd = exif_get_data_tst(fdata.sensor_port, fdata.meta_index, buffs->exif_buff.iov_base, buffs->exif_buff.iov_len, 1); // rcvd = exif_get_data_tst(fdata.sensor_port, fdata.meta_index, buffs->exif_buff.iov_base, buffs->exif_buff.iov_len, 1);
printk(KERN_DEBUG ">>> bytes received from exif driver: %u\n", rcvd); printk(KERN_DEBUG ">>> bytes received from exif driver: %u\n", rcvd);
if (rcvd > 0 && rcvd < buffs->exif_buff.iov_len) if (rcvd > 0 && rcvd < buffs->exif_buff.iov_len) {
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, buffs->exif_buff.iov_base, rcvd); // print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, buffs->exif_buff.iov_base, rcvd);
}
chunks[CHUNK_EXIF].iov_len = rcvd; chunks[CHUNK_EXIF].iov_len = rcvd;
rcvd = jpeghead_get_data(fdata.sensor_port, buffs->jpheader_buff.iov_base, buffs->jpheader_buff.iov_len, 0); rcvd = jpeghead_get_data(fdata.sensor_port, buffs->jpheader_buff.iov_base, buffs->jpheader_buff.iov_len, 0);
// rcvd = jpeghead_get_data_tst(fdata.sensor_port, buffs->jpheader_buff.iov_base, buffs->jpheader_buff.iov_len, 0); // rcvd = jpeghead_get_data_tst(fdata.sensor_port, buffs->jpheader_buff.iov_base, buffs->jpheader_buff.iov_len, 0);
printk(KERN_DEBUG ">>> bytes received from jpeghead driver: %u\n", rcvd); printk(KERN_DEBUG ">>> bytes received from jpeghead driver: %u\n", rcvd);
if (rcvd > 0 && rcvd < buffs->jpheader_buff.iov_len) { if (rcvd > 0 && rcvd < buffs->jpheader_buff.iov_len) {
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, buffs->jpheader_buff.iov_base, rcvd); // print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, buffs->jpheader_buff.iov_base, rcvd);
chunks[CHUNK_LEADER].iov_len = JPEG_MARKER_LEN; chunks[CHUNK_LEADER].iov_len = JPEG_MARKER_LEN;
chunks[CHUNK_TRAILER].iov_len = JPEG_MARKER_LEN; chunks[CHUNK_TRAILER].iov_len = JPEG_MARKER_LEN;
chunks[CHUNK_HEADER].iov_len = rcvd - chunks[CHUNK_LEADER].iov_len; chunks[CHUNK_HEADER].iov_len = rcvd - chunks[CHUNK_LEADER].iov_len;
......
...@@ -109,7 +109,7 @@ int circbuf_get_ptr(int sensor_port, size_t offset, size_t len, struct fvec *vec ...@@ -109,7 +109,7 @@ int circbuf_get_ptr(int sensor_port, size_t offset, size_t len, struct fvec *vec
if (offset + len < CCAM_DMA_SIZE) { if (offset + len < CCAM_DMA_SIZE) {
// the image is not split // the image is not split
vect_0->iov_base = circbuf_priv[sensor_port].buf_ptr + offset; vect_0->iov_base = &circbuf_priv[sensor_port].buf_ptr[BYTE2DW(offset)];
vect_0->iov_dma = circbuf_priv[sensor_port].phys_addr + offset; vect_0->iov_dma = circbuf_priv[sensor_port].phys_addr + offset;
vect_0->iov_len = len; vect_0->iov_len = len;
vect_1->iov_base = NULL; vect_1->iov_base = NULL;
...@@ -117,7 +117,7 @@ int circbuf_get_ptr(int sensor_port, size_t offset, size_t len, struct fvec *vec ...@@ -117,7 +117,7 @@ int circbuf_get_ptr(int sensor_port, size_t offset, size_t len, struct fvec *vec
vect_1->iov_dma = 0; vect_1->iov_dma = 0;
} else { } else {
// the image is split into two segments // the image is split into two segments
vect_0->iov_base = circbuf_priv[sensor_port].buf_ptr + offset; vect_0->iov_base = &circbuf_priv[sensor_port].buf_ptr[BYTE2DW(offset)];
vect_0->iov_dma = circbuf_priv[sensor_port].phys_addr + offset; vect_0->iov_dma = circbuf_priv[sensor_port].phys_addr + offset;
vect_0->iov_len = CCAM_DMA_SIZE - offset; vect_0->iov_len = CCAM_DMA_SIZE - offset;
vect_1->iov_base = circbuf_priv[sensor_port].buf_ptr; vect_1->iov_base = circbuf_priv[sensor_port].buf_ptr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment