media: rockchip: vicap: fixes build error

Signed-off-by: Zefa Chen <zefa.chen@rock-chips.com>
Change-Id: Ibe9d903c628d81ef75cf16ad564bc10764700627
This commit is contained in:
Zefa Chen
2023-06-01 16:52:25 +08:00
committed by Tao Huang
parent 0b42c92f71
commit ace9adc376
8 changed files with 70 additions and 196 deletions

View File

@@ -717,22 +717,10 @@ cif_input_fmt *get_input_fmt(struct v4l2_subdev *sd, struct v4l2_rect *rect,
fmt.format.width = ch_info.width;
fmt.format.height = ch_info.height;
fmt.format.code = ch_info.bus_fmt;
switch (ch_info.vc) {
case V4L2_MBUS_CSI2_CHANNEL_3:
csi_info->vc = 3;
break;
case V4L2_MBUS_CSI2_CHANNEL_2:
csi_info->vc = 2;
break;
case V4L2_MBUS_CSI2_CHANNEL_1:
csi_info->vc = 1;
break;
case V4L2_MBUS_CSI2_CHANNEL_0:
csi_info->vc = 0;
break;
default:
if (ch_info.vc >= 0 && ch_info.vc <= 3)
csi_info->vc = ch_info.vc;
else
csi_info->vc = 0xff;
}
if (ch_info.bus_fmt == MEDIA_BUS_FMT_SPD_2X8 ||
ch_info.bus_fmt == MEDIA_BUS_FMT_EBD_1X8) {
if (ch_info.data_type > 0)
@@ -2875,45 +2863,6 @@ static int rkcif_assign_new_buffer_pingpong_rockit(struct rkcif_stream *stream,
return ret;
}
static void rkcif_csi_get_vc_num(struct rkcif_device *dev,
unsigned int mbus_flags)
{
int i, vc_num = 0;
for (i = 0; i < RKCIF_MAX_CSI_CHANNEL; i++) {
if (mbus_flags & V4L2_MBUS_CSI2_CHANNEL_0) {
dev->channels[vc_num].vc = vc_num;
vc_num++;
mbus_flags ^= V4L2_MBUS_CSI2_CHANNEL_0;
continue;
}
if (mbus_flags & V4L2_MBUS_CSI2_CHANNEL_1) {
dev->channels[vc_num].vc = vc_num;
vc_num++;
mbus_flags ^= V4L2_MBUS_CSI2_CHANNEL_1;
continue;
}
if (mbus_flags & V4L2_MBUS_CSI2_CHANNEL_2) {
dev->channels[vc_num].vc = vc_num;
vc_num++;
mbus_flags ^= V4L2_MBUS_CSI2_CHANNEL_2;
continue;
}
if (mbus_flags & V4L2_MBUS_CSI2_CHANNEL_3) {
dev->channels[vc_num].vc = vc_num;
vc_num++;
mbus_flags ^= V4L2_MBUS_CSI2_CHANNEL_3;
continue;
}
}
dev->num_channels = vc_num ? vc_num : 1;
if (dev->num_channels == 1)
dev->channels[0].vc = 0;
}
static void rkcif_csi_set_lvds_sav_eav(struct rkcif_stream *stream,
struct csi_channel_info *channel)
{
@@ -3586,7 +3535,6 @@ static int rkcif_csi_stream_start(struct rkcif_stream *stream, unsigned int mode
{
struct rkcif_device *dev = stream->cifdev;
struct rkcif_sensor_info *active_sensor = dev->active_sensor;
unsigned int flags = active_sensor->mbus.flags;
enum v4l2_mbus_type mbus_type = active_sensor->mbus.type;
struct csi_channel_info *channel;
u32 ret = 0;
@@ -3600,8 +3548,6 @@ static int rkcif_csi_stream_start(struct rkcif_stream *stream, unsigned int mode
stream->is_change_toisp = false;
}
rkcif_csi_get_vc_num(dev, flags);
channel = &dev->channels[stream->id];
channel->id = stream->id;
if (mbus_type == V4L2_MBUS_CCP2) {
@@ -4032,7 +3978,7 @@ void rkcif_buf_queue(struct vb2_buffer *vb)
dbufs->type = BUF_LONG;
else if (stream->cifdev->hdr.hdr_mode == HDR_X3 && stream->id == 1)
dbufs->type = BUF_MIDDLE;
cifbuf->dbuf = hw_dev->mem_ops->get_dmabuf(vb->planes[0].mem_priv, O_RDWR);
cifbuf->dbuf = hw_dev->mem_ops->get_dmabuf(vb, vb->planes[0].mem_priv, O_RDWR);
if (cifbuf->dbuf)
dbufs->dbuf = cifbuf->dbuf;
list_add_tail(&dbufs->list, &stream->rx_buf_head_vicap);
@@ -4449,7 +4395,7 @@ void rkcif_do_stop_stream(struct rkcif_stream *stream,
stream->stopping = false;
}
media_pipeline_stop(&node->vdev.entity);
video_device_pipeline_stop(&node->vdev);
ret = dev->pipe.set_stream(&dev->pipe, false);
if (ret < 0)
v4l2_err(v4l2_dev, "pipeline stream-off failed error:%d\n",
@@ -4669,7 +4615,7 @@ static u32 rkcif_determine_input_mode_rk3588(struct rkcif_stream *stream)
switch (stream->cif_fmt_in->fmt_type) {
case CIF_FMT_TYPE_YUV:
if (sensor_info->mbus.type == V4L2_MBUS_BT656) {
if ((sensor_info->mbus.flags & CIF_DVP_PCLK_DUAL_EDGE) == CIF_DVP_PCLK_DUAL_EDGE)
if ((sensor_info->mbus.bus.parallel.flags & CIF_DVP_PCLK_DUAL_EDGE) == CIF_DVP_PCLK_DUAL_EDGE)
mode = INPUT_BT1120_YUV422;
else
mode = INPUT_BT656_YUV422;
@@ -4978,31 +4924,12 @@ int rkcif_update_sensor_info(struct rkcif_stream *stream)
return -ENODEV;
}
if (terminal_sensor->mbus.type == V4L2_MBUS_CSI2_DPHY ||
terminal_sensor->mbus.type == V4L2_MBUS_CSI2_CPHY ||
terminal_sensor->mbus.type == V4L2_MBUS_CCP2) {
switch (terminal_sensor->mbus.flags & V4L2_MBUS_CSI2_LANES) {
case V4L2_MBUS_CSI2_1_LANE:
terminal_sensor->lanes = 1;
break;
case V4L2_MBUS_CSI2_2_LANE:
terminal_sensor->lanes = 2;
break;
case V4L2_MBUS_CSI2_3_LANE:
terminal_sensor->lanes = 3;
break;
case V4L2_MBUS_CSI2_4_LANE:
terminal_sensor->lanes = 4;
break;
default:
v4l2_err(&stream->cifdev->v4l2_dev, "%s:get sd:%s lane num failed!\n",
__func__,
terminal_sensor->sd ?
terminal_sensor->sd->name : "null");
return -EINVAL;
}
}
if (terminal_sensor->mbus.type == V4L2_MBUS_CSI2_DPHY ||
terminal_sensor->mbus.type == V4L2_MBUS_CSI2_CPHY)
terminal_sensor->lanes = terminal_sensor->mbus.bus.mipi_csi2.num_data_lanes;
else if (terminal_sensor->mbus.type == V4L2_MBUS_CCP2)
terminal_sensor->lanes = terminal_sensor->mbus.bus.mipi_csi1.data_lane;
return ret;
}
@@ -5131,7 +5058,7 @@ static int rkcif_stream_start(struct rkcif_stream *stream, unsigned int mode)
if (dma_state)
return 0;
mbus_flags = mbus->flags;
mbus_flags = mbus->bus.parallel.flags;
if ((mbus_flags & CIF_DVP_PCLK_DUAL_EDGE) == CIF_DVP_PCLK_DUAL_EDGE) {
bt1120_edge_mode = (dev->chip_id < CHIP_RK3588_CIF ?
BT1120_CLOCK_DOUBLE_EDGES : BT1120_CLOCK_DOUBLE_EDGES_RK3588);
@@ -5669,7 +5596,7 @@ int rkcif_do_start_stream(struct rkcif_stream *stream, unsigned int mode)
goto runtime_put;
if (stream->cur_stream_mode == RKCIF_STREAM_MODE_NONE) {
ret = media_pipeline_start(&node->vdev.entity, &dev->pipe.pipe);
ret = video_device_pipeline_start(&node->vdev, &dev->pipe.pipe);
if (ret < 0) {
v4l2_err(&dev->v4l2_dev, "start pipeline failed %d\n",
ret);

View File

@@ -12,6 +12,8 @@
static struct rockit_rkcif_cfg *rockit_rkcif_cfg;
struct rkcif_rockit_buffer {
struct vb2_buffer vb;
struct vb2_queue vb2_queue;
struct rkcif_buffer cif_buf;
struct dma_buf *dmabuf;
void *mpi_mem;
@@ -24,6 +26,21 @@ struct rkcif_rockit_buffer {
};
};
static void rkcif_init_rockit_vb2(struct rkcif_device *dev,
struct rkcif_rockit_buffer *buf)
{
unsigned long attrs = DMA_ATTR_NO_KERNEL_MAPPING;
memset(&buf->vb2_queue, 0, sizeof(struct vb2_queue));
memset(&buf->vb, 0, sizeof(struct vb2_buffer));
buf->vb2_queue.gfp_flags = GFP_KERNEL | GFP_DMA32;
buf->vb2_queue.dma_dir = DMA_BIDIRECTIONAL;
if (dev->hw_dev->is_dma_contig)
attrs |= DMA_ATTR_FORCE_CONTIGUOUS;
buf->vb2_queue.dma_attrs = attrs;
buf->vb.vb2_queue = &buf->vb2_queue;
}
static struct rkcif_stream *rkcif_rockit_get_stream(struct rockit_rkcif_cfg *input_rockit_cfg)
{
struct rkcif_device *cif_dev = NULL;
@@ -131,11 +148,12 @@ int rkcif_rockit_buf_queue(struct rockit_rkcif_cfg *input_rockit_cfg)
rkcif_buf = stream_cfg->rkcif_buff[i];
rkcif_buf->mpi_buf = input_rockit_cfg->mpibuf;
rkcif_init_rockit_vb2(stream->cifdev, rkcif_buf);
mem = g_ops->attach_dmabuf(stream->cifdev->hw_dev->dev,
mem = g_ops->attach_dmabuf(&rkcif_buf->vb,
stream->cifdev->hw_dev->dev,
input_rockit_cfg->buf,
input_rockit_cfg->buf->size,
DMA_BIDIRECTIONAL);
input_rockit_cfg->buf->size);
if (IS_ERR(mem))
pr_err("the g_ops->attach_dmabuf is error!\n");
@@ -147,10 +165,10 @@ int rkcif_rockit_buf_queue(struct rockit_rkcif_cfg *input_rockit_cfg)
pr_err("the g_ops->map_dmabuf is error!\n");
if (stream->cifdev->hw_dev->is_dma_sg_ops) {
sg_tbl = (struct sg_table *)g_ops->cookie(mem);
sg_tbl = (struct sg_table *)g_ops->cookie(&rkcif_buf->vb, mem);
rkcif_buf->buff_addr = sg_dma_address(sg_tbl->sgl);
} else {
rkcif_buf->buff_addr = *((u32 *)g_ops->cookie(mem));
rkcif_buf->buff_addr = *((u32 *)g_ops->cookie(&rkcif_buf->vb, mem));
}
get_dma_buf(input_rockit_cfg->buf);
} else {

View File

@@ -7,10 +7,24 @@
#include "dev.h"
#include "common.h"
static void rkcif_init_dummy_vb2(struct rkcif_device *dev,
struct rkcif_dummy_buffer *buf)
{
unsigned long attrs = buf->is_need_vaddr ? 0 : DMA_ATTR_NO_KERNEL_MAPPING;
memset(&buf->vb2_queue, 0, sizeof(struct vb2_queue));
memset(&buf->vb, 0, sizeof(struct vb2_buffer));
buf->vb2_queue.gfp_flags = GFP_KERNEL | GFP_DMA32;
buf->vb2_queue.dma_dir = DMA_BIDIRECTIONAL;
if (dev->hw_dev->is_dma_contig)
attrs |= DMA_ATTR_FORCE_CONTIGUOUS;
buf->vb2_queue.dma_attrs = attrs;
buf->vb.vb2_queue = &buf->vb2_queue;
}
int rkcif_alloc_buffer(struct rkcif_device *dev,
struct rkcif_dummy_buffer *buf)
{
unsigned long attrs = buf->is_need_vaddr ? 0 : DMA_ATTR_NO_KERNEL_MAPPING;
const struct vb2_mem_ops *g_ops = dev->hw_dev->mem_ops;
struct sg_table *sg_tbl;
void *mem_priv;
@@ -21,11 +35,10 @@ int rkcif_alloc_buffer(struct rkcif_device *dev,
goto err;
}
if (dev->hw_dev->is_dma_contig)
attrs |= DMA_ATTR_FORCE_CONTIGUOUS;
rkcif_init_dummy_vb2(dev, buf);
buf->size = PAGE_ALIGN(buf->size);
mem_priv = g_ops->alloc(dev->hw_dev->dev, attrs, buf->size,
DMA_BIDIRECTIONAL, GFP_KERNEL | GFP_DMA32);
mem_priv = g_ops->alloc(&buf->vb, dev->hw_dev->dev, buf->size);
if (IS_ERR_OR_NULL(mem_priv)) {
ret = -ENOMEM;
goto err;
@@ -33,16 +46,16 @@ int rkcif_alloc_buffer(struct rkcif_device *dev,
buf->mem_priv = mem_priv;
if (dev->hw_dev->is_dma_sg_ops) {
sg_tbl = (struct sg_table *)g_ops->cookie(mem_priv);
sg_tbl = (struct sg_table *)g_ops->cookie(&buf->vb, mem_priv);
buf->dma_addr = sg_dma_address(sg_tbl->sgl);
g_ops->prepare(mem_priv);
} else {
buf->dma_addr = *((dma_addr_t *)g_ops->cookie(mem_priv));
buf->dma_addr = *((dma_addr_t *)g_ops->cookie(&buf->vb, mem_priv));
}
if (buf->is_need_vaddr)
buf->vaddr = g_ops->vaddr(mem_priv);
buf->vaddr = g_ops->vaddr(&buf->vb, mem_priv);
if (buf->is_need_dbuf) {
buf->dbuf = g_ops->get_dmabuf(mem_priv, O_RDWR);
buf->dbuf = g_ops->get_dmabuf(&buf->vb, mem_priv, O_RDWR);
if (buf->is_need_dmafd) {
buf->dma_fd = dma_buf_fd(buf->dbuf, O_CLOEXEC);
if (buf->dma_fd < 0) {

View File

@@ -1503,26 +1503,11 @@ static int subdev_notifier_complete(struct v4l2_async_notifier *notifier)
}
}
if (sensor->mbus.type == V4L2_MBUS_CCP2 ||
sensor->mbus.type == V4L2_MBUS_CSI2_DPHY ||
if (sensor->mbus.type == V4L2_MBUS_CSI2_DPHY ||
sensor->mbus.type == V4L2_MBUS_CSI2_CPHY) {
switch (sensor->mbus.flags & V4L2_MBUS_CSI2_LANES) {
case V4L2_MBUS_CSI2_1_LANE:
sensor->lanes = 1;
break;
case V4L2_MBUS_CSI2_2_LANE:
sensor->lanes = 2;
break;
case V4L2_MBUS_CSI2_3_LANE:
sensor->lanes = 3;
break;
case V4L2_MBUS_CSI2_4_LANE:
sensor->lanes = 4;
break;
default:
sensor->lanes = 1;
}
sensor->lanes = sensor->mbus.bus.mipi_csi2.num_data_lanes;
} else if (sensor->mbus.type == V4L2_MBUS_CCP2) {
sensor->lanes = sensor->mbus.bus.mipi_csi1.data_lane;
}
if (sensor->mbus.type == V4L2_MBUS_CCP2) {
@@ -1620,7 +1605,6 @@ static int rkcif_fwnode_parse(struct device *dev,
{
struct rkcif_async_subdev *rk_asd =
container_of(asd, struct rkcif_async_subdev, asd);
struct v4l2_mbus_config_parallel *bus = &vep->bus.parallel;
if (vep->bus_type != V4L2_MBUS_BT656 &&
vep->bus_type != V4L2_MBUS_PARALLEL &&
@@ -1631,16 +1615,6 @@ static int rkcif_fwnode_parse(struct device *dev,
rk_asd->mbus.type = vep->bus_type;
if (vep->bus_type == V4L2_MBUS_CSI2_DPHY ||
vep->bus_type == V4L2_MBUS_CSI2_CPHY) {
rk_asd->mbus.flags = vep->bus.mipi_csi2.flags;
rk_asd->lanes = vep->bus.mipi_csi2.num_data_lanes;
} else if (vep->bus_type == V4L2_MBUS_CCP2) {
rk_asd->lanes = vep->bus.mipi_csi1.data_lane;
} else {
rk_asd->mbus.flags = bus->flags;
}
return 0;
}

View File

@@ -74,6 +74,8 @@ struct rkcif_multi_sync_config {
};
struct rkcif_dummy_buffer {
struct vb2_buffer vb;
struct vb2_queue vb2_queue;
struct list_head list;
struct dma_buf *dbuf;
dma_addr_t dma_addr;

View File

@@ -125,25 +125,7 @@ static void csi2_update_sensor_info(struct csi2_dev *csi2)
csi2->dsi_input_en = 0;
}
csi2->bus.flags = mbus.flags;
switch (csi2->bus.flags & V4L2_MBUS_CSI2_LANES) {
case V4L2_MBUS_CSI2_1_LANE:
csi2->bus.num_data_lanes = 1;
break;
case V4L2_MBUS_CSI2_2_LANE:
csi2->bus.num_data_lanes = 2;
break;
case V4L2_MBUS_CSI2_3_LANE:
csi2->bus.num_data_lanes = 3;
break;
case V4L2_MBUS_CSI2_4_LANE:
csi2->bus.num_data_lanes = 4;
break;
default:
v4l2_warn(&csi2->sd, "lane num is invalid\n");
csi2->bus.num_data_lanes = 0;
break;
}
csi2->bus = mbus.bus.mipi_csi2;
}
@@ -500,8 +482,8 @@ static int csi2_g_mbus_config(struct v4l2_subdev *sd, unsigned int pad_id,
ret = v4l2_subdev_call(sensor_sd, pad, get_mbus_config, 0, mbus);
if (ret) {
mbus->type = V4L2_MBUS_CSI2_DPHY;
mbus->flags = csi2->bus.flags;
mbus->flags |= BIT(csi2->bus.num_data_lanes - 1);
mbus->bus.mipi_csi2.flags = csi2->bus.flags;
mbus->bus.mipi_csi2.flags |= BIT(csi2->bus.num_data_lanes - 1);
}
return 0;
@@ -637,16 +619,6 @@ static int csi2_parse_endpoint(struct device *dev,
struct v4l2_fwnode_endpoint *vep,
struct v4l2_async_subdev *asd)
{
struct v4l2_subdev *sd = dev_get_drvdata(dev);
struct csi2_dev *csi2 = sd_to_dev(sd);
if (vep->base.port != 0) {
dev_err(dev, "The csi host node needs to parse port 0\n");
return -EINVAL;
}
csi2->bus = vep->bus.mipi_csi2;
return 0;
}

View File

@@ -248,7 +248,7 @@ static void rkcif_show_format(struct rkcif_device *dev, struct seq_file *f)
struct v4l2_rect *rect = &sensor->raw_rect;
struct v4l2_subdev_frame_interval *interval = &sensor->fi;
struct v4l2_subdev_selection *sel = &sensor->selection;
u32 i, mbus_flags;
u32 mbus_flags;
u64 fps, timestamp0, timestamp1;
unsigned long flags;
u32 time_val = 0;
@@ -260,9 +260,9 @@ static void rkcif_show_format(struct rkcif_device *dev, struct seq_file *f)
seq_puts(f, "Input Info:\n");
seq_printf(f, "\tsrc subdev:%s\n", sensor->sd->name);
mbus_flags = sensor->mbus.flags;
if (sensor->mbus.type == V4L2_MBUS_PARALLEL ||
sensor->mbus.type == V4L2_MBUS_BT656) {
mbus_flags = sensor->mbus.bus.parallel.flags;
seq_printf(f, "\tinterface:%s\n",
sensor->mbus.type == V4L2_MBUS_PARALLEL ? "BT601" : "BT656/BT1120");
seq_printf(f, "\thref_pol:%s\n",
@@ -275,16 +275,6 @@ static void rkcif_show_format(struct rkcif_device *dev, struct seq_file *f)
sensor->mbus.type == V4L2_MBUS_CSI2_CPHY ? "mipi csi2 cphy" :
sensor->mbus.type == V4L2_MBUS_CCP2 ? "lvds" : "unknown");
seq_printf(f, "\tlanes:%d\n", sensor->lanes);
seq_puts(f, "\tvc channel:");
if (mbus_flags & V4L2_MBUS_CSI2_CHANNELS) {
for (i = 0; i < 4; i++) {
if ((mbus_flags >> (4 + i)) & 0x1)
seq_printf(f, " %d", i);
}
seq_puts(f, "\n");
} else {
seq_puts(f, "unknown\n");
}
}
seq_printf(f, "\thdr mode: %s\n",

View File

@@ -108,11 +108,6 @@ static int sditf_g_mbus_config(struct v4l2_subdev *sd, unsigned int pad_id,
if (cif_dev->active_sensor) {
sensor_sd = cif_dev->active_sensor->sd;
return v4l2_subdev_call(sensor_sd, pad, get_mbus_config, 0, config);
} else {
config->type = V4L2_MBUS_CSI2_DPHY;
config->flags = V4L2_MBUS_CSI2_CHANNEL_0 |
V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
return 0;
}
return -EINVAL;
@@ -945,7 +940,7 @@ static int sditf_fwnode_parse(struct device *dev,
if (vep->bus_type == V4L2_MBUS_CSI2_DPHY ||
vep->bus_type == V4L2_MBUS_CSI2_CPHY) {
config->type = vep->bus_type;
config->flags = vep->bus.mipi_csi2.flags;
config->bus.mipi_csi2.flags = vep->bus.mipi_csi2.flags;
s_asd->lanes = vep->bus.mipi_csi2.num_data_lanes;
} else if (vep->bus_type == V4L2_MBUS_CCP2) {
config->type = vep->bus_type;
@@ -955,23 +950,6 @@ static int sditf_fwnode_parse(struct device *dev,
return -EINVAL;
}
switch (s_asd->lanes) {
case 1:
config->flags |= V4L2_MBUS_CSI2_1_LANE;
break;
case 2:
config->flags |= V4L2_MBUS_CSI2_2_LANE;
break;
case 3:
config->flags |= V4L2_MBUS_CSI2_3_LANE;
break;
case 4:
config->flags |= V4L2_MBUS_CSI2_4_LANE;
break;
default:
return -EINVAL;
}
return 0;
}