Skip to content

Commit da1484c

Browse files
Rahi374pinchartl
authored andcommitted
media: rkisp1: Support i.MX8MP's 34-bit DMA
On the ISP that is integrated in the i.MX8MP, DMA addresses have been extended to 34 bits, with the 32 MSBs stored in the DMA address registers and the 2 LSBs set to 0. To support this: - Shift the addresses to the right by 2 when writing to registers - Set the dma mask to 34 bits - Use dma_addr_t instead of u32 when storing the addresses Signed-off-by: Paul Elder <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: Tomi Valkeinen <[email protected]> Tested-by: Alexander Stein <[email protected]> Tested-by: Adam Ford <[email protected]> Reviewed-by: Tomi Valkeinen <[email protected]> Signed-off-by: Laurent Pinchart <[email protected]>
1 parent fdac4ce commit da1484c

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -648,19 +648,21 @@ static void rkisp1_dummy_buf_destroy(struct rkisp1_capture *cap)
648648

649649
static void rkisp1_set_next_buf(struct rkisp1_capture *cap)
650650
{
651+
u8 shift = rkisp1_has_feature(cap->rkisp1, DMA_34BIT) ? 2 : 0;
652+
651653
cap->buf.curr = cap->buf.next;
652654
cap->buf.next = NULL;
653655

654656
if (!list_empty(&cap->buf.queue)) {
655-
u32 *buff_addr;
657+
dma_addr_t *buff_addr;
656658

657659
cap->buf.next = list_first_entry(&cap->buf.queue, struct rkisp1_buffer, queue);
658660
list_del(&cap->buf.next->queue);
659661

660662
buff_addr = cap->buf.next->buff_addr;
661663

662664
rkisp1_write(cap->rkisp1, cap->config->mi.y_base_ad_init,
663-
buff_addr[RKISP1_PLANE_Y]);
665+
buff_addr[RKISP1_PLANE_Y] >> shift);
664666
/*
665667
* In order to support grey format we capture
666668
* YUV422 planar format from the camera and
@@ -669,29 +671,29 @@ static void rkisp1_set_next_buf(struct rkisp1_capture *cap)
669671
if (cap->pix.cfg->fourcc == V4L2_PIX_FMT_GREY) {
670672
rkisp1_write(cap->rkisp1,
671673
cap->config->mi.cb_base_ad_init,
672-
cap->buf.dummy.dma_addr);
674+
cap->buf.dummy.dma_addr >> shift);
673675
rkisp1_write(cap->rkisp1,
674676
cap->config->mi.cr_base_ad_init,
675-
cap->buf.dummy.dma_addr);
677+
cap->buf.dummy.dma_addr >> shift);
676678
} else {
677679
rkisp1_write(cap->rkisp1,
678680
cap->config->mi.cb_base_ad_init,
679-
buff_addr[RKISP1_PLANE_CB]);
681+
buff_addr[RKISP1_PLANE_CB] >> shift);
680682
rkisp1_write(cap->rkisp1,
681683
cap->config->mi.cr_base_ad_init,
682-
buff_addr[RKISP1_PLANE_CR]);
684+
buff_addr[RKISP1_PLANE_CR] >> shift);
683685
}
684686
} else {
685687
/*
686688
* Use the dummy space allocated by dma_alloc_coherent to
687689
* throw data if there is no available buffer.
688690
*/
689691
rkisp1_write(cap->rkisp1, cap->config->mi.y_base_ad_init,
690-
cap->buf.dummy.dma_addr);
692+
cap->buf.dummy.dma_addr >> shift);
691693
rkisp1_write(cap->rkisp1, cap->config->mi.cb_base_ad_init,
692-
cap->buf.dummy.dma_addr);
694+
cap->buf.dummy.dma_addr >> shift);
693695
rkisp1_write(cap->rkisp1, cap->config->mi.cr_base_ad_init,
694-
cap->buf.dummy.dma_addr);
696+
cap->buf.dummy.dma_addr >> shift);
695697
}
696698

697699
/* Set plane offsets */

drivers/media/platform/rockchip/rkisp1/rkisp1-common.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ enum rkisp1_isp_pad {
114114
* @RKISP1_FEATURE_MAIN_STRIDE: The ISP supports configurable stride on the main path
115115
* @RKISP1_FEATURE_SELF_PATH: The ISP has a self path
116116
* @RKISP1_FEATURE_DUAL_CROP: The ISP has the dual crop block at the resizer input
117+
* @RKISP1_FEATURE_DMA_34BIT: The ISP uses 34-bit DMA addresses
117118
*
118119
* The ISP features are stored in a bitmask in &rkisp1_info.features and allow
119120
* the driver to implement support for features present in some ISP versions
@@ -124,6 +125,7 @@ enum rkisp1_feature {
124125
RKISP1_FEATURE_MAIN_STRIDE = BIT(1),
125126
RKISP1_FEATURE_SELF_PATH = BIT(2),
126127
RKISP1_FEATURE_DUAL_CROP = BIT(3),
128+
RKISP1_FEATURE_DMA_34BIT = BIT(4),
127129
};
128130

129131
#define rkisp1_has_feature(rkisp1, feature) \
@@ -239,7 +241,7 @@ struct rkisp1_vdev_node {
239241
struct rkisp1_buffer {
240242
struct vb2_v4l2_buffer vb;
241243
struct list_head queue;
242-
u32 buff_addr[VIDEO_MAX_PLANES];
244+
dma_addr_t buff_addr[VIDEO_MAX_PLANES];
243245
};
244246

245247
/*

drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ static int rkisp1_probe(struct platform_device *pdev)
531531
struct rkisp1_device *rkisp1;
532532
struct v4l2_device *v4l2_dev;
533533
unsigned int i;
534+
u64 dma_mask;
534535
int ret, irq;
535536
u32 cif_id;
536537

@@ -544,6 +545,13 @@ static int rkisp1_probe(struct platform_device *pdev)
544545
dev_set_drvdata(dev, rkisp1);
545546
rkisp1->dev = dev;
546547

548+
dma_mask = rkisp1_has_feature(rkisp1, DMA_34BIT) ? DMA_BIT_MASK(34) :
549+
DMA_BIT_MASK(32);
550+
551+
ret = dma_set_mask_and_coherent(dev, dma_mask);
552+
if (ret)
553+
return ret;
554+
547555
mutex_init(&rkisp1->stream_lock);
548556

549557
rkisp1->base_addr = devm_platform_ioremap_resource(pdev, 0);

0 commit comments

Comments
 (0)