summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChanghuang Liang <changhuang.liang@starfivetech.com>2024-01-12 12:27:46 +0300
committerChanghuang Liang <changhuang.liang@starfivetech.com>2024-01-12 12:56:15 +0300
commitebd059682efd7c8b36d1f8c1606f89ae6236c6af (patch)
treeb70ed81cced59448db02885c1edb0a4581a6a30b
parentc1d57ddbd8dbd3a27bbb79350e5eebf9efa5dcc9 (diff)
downloadlinux-ebd059682efd7c8b36d1f8c1606f89ae6236c6af.tar.xz
media: starfive: Update flush l2cache interface
Improve l2cache flush performance. And adjust ISP sc buffer size in pixel format. Signed-off-by: Changhuang Liang <changhuang.liang@starfivetech.com>
-rw-r--r--drivers/media/platform/starfive/v4l2_driver/stf_video.c10
-rw-r--r--drivers/media/platform/starfive/v4l2_driver/stf_vin.c13
-rw-r--r--drivers/media/platform/starfive/v4l2_driver/stf_vin.h3
3 files changed, 18 insertions, 8 deletions
diff --git a/drivers/media/platform/starfive/v4l2_driver/stf_video.c b/drivers/media/platform/starfive/v4l2_driver/stf_video.c
index 8a5e5a846f96..38876d4329c1 100644
--- a/drivers/media/platform/starfive/v4l2_driver/stf_video.c
+++ b/drivers/media/platform/starfive/v4l2_driver/stf_video.c
@@ -216,6 +216,11 @@ static int __video_try_fmt(struct stfcamss_video *video,
pix->height, fi->bpp[0]);
st_info(ST_VIDEO, "i = %d, s = 0x%x\n", i, pix->sizeimage);
}
+
+ if (stf_vin_map_isp_pad(video->id, STF_ISP_PAD_SRC)
+ == STF_ISP_PAD_SRC_SCD_Y)
+ pix->sizeimage = ISP_SCD_Y_BUFFER_SIZE;
+
return 0;
}
@@ -285,11 +290,6 @@ static int video_queue_setup(struct vb2_queue *q,
if (!sizes[0])
st_err(ST_VIDEO, "%s: error size is zero!!!\n", __func__);
}
- if ((stf_vin_map_isp_pad(video->id, STF_ISP_PAD_SRC)
- == STF_ISP_PAD_SRC_SCD_Y) &&
- sizes[0] < ISP_SCD_Y_BUFFER_SIZE) {
- sizes[0] = ISP_SCD_Y_BUFFER_SIZE;
- }
st_info(ST_VIDEO, "%s, planes = %d, size = %d\n",
__func__, *num_planes, sizes[0]);
diff --git a/drivers/media/platform/starfive/v4l2_driver/stf_vin.c b/drivers/media/platform/starfive/v4l2_driver/stf_vin.c
index dc30b018e684..8be849aab420 100644
--- a/drivers/media/platform/starfive/v4l2_driver/stf_vin.c
+++ b/drivers/media/platform/starfive/v4l2_driver/stf_vin.c
@@ -362,7 +362,10 @@ static void vin_buf_l2cache_flush(struct vin_output *output)
if (!list_empty(&output->pending_bufs)) {
list_for_each_entry(buffer, &output->pending_bufs, queue) {
- sifive_l2_flush64_range(buffer->addr[0], buffer->sizeimage);
+ if (buffer->sizeimage > STF_VIN_CRITICAL_CACHE_SIZE)
+ sifive_ccache_flush_entire();
+ else
+ sifive_l2_flush64_range(buffer->addr[0], buffer->sizeimage);
}
}
}
@@ -1171,8 +1174,12 @@ static void vin_buffer_done(struct vin_line *line, struct vin_params *params)
* which will not update cache by default.
* Flush L2 cache to make sure data is updated.
*/
- if (ready_buf->vb.vb2_buf.memory == VB2_MEMORY_MMAP)
- sifive_l2_flush64_range(ready_buf->addr[0], ready_buf->sizeimage);
+ if (ready_buf->vb.vb2_buf.memory == VB2_MEMORY_MMAP) {
+ if (ready_buf->sizeimage > STF_VIN_CRITICAL_CACHE_SIZE)
+ sifive_ccache_flush_entire();
+ else
+ sifive_l2_flush64_range(ready_buf->addr[0], ready_buf->sizeimage);
+ }
vb2_buffer_done(&ready_buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
}
diff --git a/drivers/media/platform/starfive/v4l2_driver/stf_vin.h b/drivers/media/platform/starfive/v4l2_driver/stf_vin.h
index 6b331b738440..812e7a91ed9f 100644
--- a/drivers/media/platform/starfive/v4l2_driver/stf_vin.h
+++ b/drivers/media/platform/starfive/v4l2_driver/stf_vin.h
@@ -21,6 +21,8 @@
#define STF_VIN_PAD_SRC 1
#define STF_VIN_PADS_NUM 2
+#define STF_VIN_CRITICAL_CACHE_SIZE 0x80000
+
struct vin2_format {
u32 code;
u8 bpp;
@@ -169,6 +171,7 @@ struct stf_vin2_dev {
};
extern void sifive_l2_flush64_range(unsigned long start, unsigned long len);
+extern void sifive_ccache_flush_entire(void);
extern int stf_vin_subdev_init(struct stfcamss *stfcamss);
extern int stf_vin_register(struct stf_vin2_dev *vin_dev,
struct v4l2_device *v4l2_dev);