media: rockchip: vicap: support use reserved mem for aov when run with thunderboot mode

Signed-off-by: Zefa Chen <zefa.chen@rock-chips.com>
Change-Id: Ic0dca3b4e8b32c217abece05a6566beb54bc6eaa
This commit is contained in:
Zefa Chen
2023-12-28 09:26:33 +08:00
committed by Tao Huang
parent 730004820b
commit 4de536c973
4 changed files with 30 additions and 8 deletions

View File

@@ -4569,6 +4569,7 @@ void rkcif_free_rx_buf(struct rkcif_stream *stream, int buf_num)
phys_addr_t resmem_free_start;
phys_addr_t resmem_free_end;
u32 share_head_size = 0;
u32 rtt_min_size = 0;
if (!priv)
return;
@@ -4577,7 +4578,7 @@ void rkcif_free_rx_buf(struct rkcif_stream *stream, int buf_num)
if (!sd)
return;
if (dev->is_rtt_suspend && dev->is_thunderboot) {
if ((dev->is_rtt_suspend || dev->is_aov_reserved) && dev->is_thunderboot) {
stream->curr_buf_toisp = NULL;
stream->next_buf_toisp = NULL;
INIT_LIST_HEAD(&stream->rx_buf_head);
@@ -4596,7 +4597,14 @@ void rkcif_free_rx_buf(struct rkcif_stream *stream, int buf_num)
v4l2_info(&stream->cifdev->v4l2_dev,
"share mem head error, rtt head size %d, arm head size %d\n",
dev->share_mem_size, share_head_size);
resmem_free_start = dev->resmem_pa + share_head_size + dev->nr_buf_size;
if (share_head_size + dev->nr_buf_size > stream->pixm.plane_fmt[0].sizeimage)
rtt_min_size = share_head_size + dev->nr_buf_size;
else
rtt_min_size = stream->pixm.plane_fmt[0].sizeimage;
if (dev->is_rtt_suspend)
resmem_free_start = dev->resmem_pa + rtt_min_size;
else
resmem_free_start = dev->resmem_pa + stream->pixm.plane_fmt[0].sizeimage;
resmem_free_end = dev->resmem_pa + dev->resmem_size;
v4l2_info(&stream->cifdev->v4l2_dev,
"free reserved mem start 0x%x, end 0x%x, share_head_size 0x%x, nr_buf_size 0x%x\n",
@@ -4604,6 +4612,10 @@ void rkcif_free_rx_buf(struct rkcif_stream *stream, int buf_num)
free_reserved_area(phys_to_virt(resmem_free_start),
phys_to_virt(resmem_free_end),
-1, "rkisp_thunderboot");
if (dev->is_rtt_suspend)
dev->resmem_size = rtt_min_size;
else
dev->resmem_size = stream->pixm.plane_fmt[0].sizeimage;
}
atomic_set(&stream->buf_cnt, 0);
stream->total_buf_num = 0;
@@ -4692,7 +4704,7 @@ int rkcif_init_rx_buf(struct rkcif_stream *stream, int buf_num)
dummy->size = pixm->plane_fmt[0].sizeimage;
dummy->is_need_vaddr = true;
dummy->is_need_dbuf = true;
if (dev->is_thunderboot) {
if (dev->is_thunderboot || dev->is_rtt_suspend || dev->is_aov_reserved) {
if (i == 0)
rkcif_get_resmem_head(dev);
buf->buf_idx = i;
@@ -7295,8 +7307,6 @@ static bool rkcif_check_can_be_online(struct rkcif_device *cif_dev)
static int rkcif_do_reset_work(struct rkcif_device *cif_dev,
enum rkmodule_reset_src reset_src);
static bool rkcif_check_single_dev_stream_on(struct rkcif_hw *hw);
static long rkcif_ioctl_default(struct file *file, void *fh,
bool valid_prio, unsigned int cmd, void *arg)
{
@@ -10467,7 +10477,7 @@ static bool rkcif_check_buffer_prepare(struct rkcif_stream *stream)
return is_update;
}
static bool rkcif_check_single_dev_stream_on(struct rkcif_hw *hw)
bool rkcif_check_single_dev_stream_on(struct rkcif_hw *hw)
{
struct rkcif_device *cif_dev = NULL;
struct rkcif_stream *stream = NULL;

View File

@@ -2152,6 +2152,7 @@ static int rkcif_get_reserved_mem(struct rkcif_device *cif_dev)
cif_dev->is_thunderboot = false;
cif_dev->is_rtt_suspend = false;
cif_dev->is_aov_reserved = false;
/* Get reserved memory region from Device-tree */
np = of_parse_phandle(dev->of_node, "memory-region-thunderboot", 0);
if (!np) {
@@ -2173,6 +2174,8 @@ static int rkcif_get_reserved_mem(struct rkcif_device *cif_dev)
if (device_property_read_bool(dev, "rtt-suspend"))
cif_dev->is_rtt_suspend = true;
if (device_property_read_bool(dev, "aov-reserved"))
cif_dev->is_aov_reserved = true;
if (IS_ENABLED(CONFIG_VIDEO_ROCKCHIP_THUNDER_BOOT_ISP))
cif_dev->is_thunderboot = true;
dev_info(dev, "Allocated reserved memory, paddr: 0x%x, size 0x%x\n",

View File

@@ -907,6 +907,7 @@ struct rkcif_device {
bool is_rdbk_to_online;
bool is_support_tools;
bool is_rtt_suspend;
bool is_aov_reserved;
bool sensor_state_change;
bool is_toisp_reset;
int rdbk_debug;
@@ -1032,4 +1033,6 @@ static inline u64 rkcif_time_get_ns(struct rkcif_device *dev)
return ktime_get_ns();
}
bool rkcif_check_single_dev_stream_on(struct rkcif_hw *hw);
#endif

View File

@@ -828,6 +828,7 @@ static int sditf_s_rx_buffer(struct v4l2_subdev *sd,
u32 diff_time = 1000000;
u32 early_time = 0;
bool is_free = false;
bool is_single_dev = false;
if (!buf) {
v4l2_err(&cif_dev->v4l2_dev, "buf is NULL\n");
@@ -868,9 +869,12 @@ static int sditf_s_rx_buffer(struct v4l2_subdev *sd,
stream->last_rx_buf_idx = dbufs->sequence + 1;
atomic_inc(&stream->buf_cnt);
is_single_dev = rkcif_check_single_dev_stream_on(cif_dev->hw_dev);
if (!list_empty(&stream->rx_buf_head) &&
cif_dev->is_thunderboot &&
(!cif_dev->is_rtt_suspend) &&
((!cif_dev->is_rtt_suspend &&
!cif_dev->is_aov_reserved) ||
!is_single_dev) &&
(dbufs->type == BUF_SHORT ||
(dbufs->type != BUF_SHORT && (!dbufs->is_switch)))) {
spin_lock_irqsave(&cif_dev->buffree_lock, buffree_flags);
@@ -899,7 +903,9 @@ static int sditf_s_rx_buffer(struct v4l2_subdev *sd,
offset = rx_buf->dummy.size - stream->pixm.plane_fmt[0].bytesperline * 3;
memset(rx_buf->dummy.vaddr + offset,
0x00, stream->pixm.plane_fmt[0].bytesperline * 3);
if (cif_dev->is_thunderboot)
if (cif_dev->is_thunderboot ||
cif_dev->is_rtt_suspend ||
cif_dev->is_aov_reserved)
dma_sync_single_for_device(cif_dev->dev,
rx_buf->dummy.dma_addr + rx_buf->dummy.size -
stream->pixm.plane_fmt[0].bytesperline * 3,