mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 11:50:43 +09:00
drivers: media: platform: rockchip: cif: fix compile failed for kernel-4.19
Signed-off-by: Allon Huang <allon.huang@rock-chips.com> Change-Id: I9d58702f5c948dd2d36f2b555fcda0e00c773266
This commit is contained in:
@@ -885,26 +885,20 @@ static void rkcif_stream_stop(struct rkcif_stream *stream)
|
||||
}
|
||||
|
||||
static int rkcif_queue_setup(struct vb2_queue *queue,
|
||||
const void *parg,
|
||||
unsigned int *num_buffers,
|
||||
unsigned int *num_planes,
|
||||
unsigned int sizes[],
|
||||
void *alloc_ctxs[])
|
||||
struct device *alloc_ctxs[])
|
||||
{
|
||||
struct rkcif_stream *stream = queue->drv_priv;
|
||||
struct rkcif_device *dev = stream->cifdev;
|
||||
const struct v4l2_format *pfmt = parg;
|
||||
const struct v4l2_pix_format_mplane *pixm;
|
||||
const struct v4l2_pix_format_mplane *pixm = NULL;
|
||||
const struct cif_output_fmt *cif_fmt;
|
||||
u32 i;
|
||||
|
||||
if (pfmt) {
|
||||
pixm = &pfmt->fmt.pix_mp;
|
||||
cif_fmt = find_output_fmt(stream, pixm->pixelformat);
|
||||
} else {
|
||||
pixm = &stream->pixm;
|
||||
cif_fmt = stream->cif_fmt_out;
|
||||
}
|
||||
|
||||
pixm = &stream->pixm;
|
||||
cif_fmt = stream->cif_fmt_out;
|
||||
|
||||
*num_planes = cif_fmt->mplanes;
|
||||
|
||||
@@ -915,7 +909,6 @@ static int rkcif_queue_setup(struct vb2_queue *queue,
|
||||
plane_fmt = &pixm->plane_fmt[i];
|
||||
sizes[i] = plane_fmt->sizeimage / pixm->height * h;
|
||||
|
||||
alloc_ctxs[i] = dev->alloc_ctx;
|
||||
}
|
||||
|
||||
v4l2_dbg(1, rkcif_debug, &dev->v4l2_dev, "%s count %d, size %d\n",
|
||||
@@ -1032,7 +1025,7 @@ static void rkcif_stop_streaming(struct vb2_queue *queue)
|
||||
stream->stopping = false;
|
||||
}
|
||||
|
||||
media_entity_pipeline_stop(&node->vdev.entity);
|
||||
media_pipeline_stop(&node->vdev.entity);
|
||||
ret = dev->pipe.set_stream(&dev->pipe, false);
|
||||
if (ret < 0)
|
||||
v4l2_err(v4l2_dev, "pipeline stream-off failed error:%d\n",
|
||||
@@ -1404,7 +1397,7 @@ static int rkcif_start_streaming(struct vb2_queue *queue, unsigned int count)
|
||||
if (ret < 0)
|
||||
goto stop_stream;
|
||||
|
||||
ret = media_entity_pipeline_start(&node->vdev.entity, &dev->pipe.pipe);
|
||||
ret = media_pipeline_start(&node->vdev.entity, &dev->pipe.pipe);
|
||||
if (ret < 0) {
|
||||
v4l2_err(&dev->v4l2_dev, "start pipeline failed %d\n",
|
||||
ret);
|
||||
@@ -1910,7 +1903,7 @@ static int rkcif_register_stream_vdev(struct rkcif_stream *stream,
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = media_entity_init(&vdev->entity, 1, &node->pad, 0);
|
||||
ret = media_entity_pads_init(&vdev->entity, 1, &node->pad);
|
||||
if (ret < 0)
|
||||
goto unreg;
|
||||
|
||||
@@ -1968,7 +1961,7 @@ static void rkcif_vb_done_oneframe(struct rkcif_stream *stream,
|
||||
vb2_set_plane_payload(&vb_done->vb2_buf, i,
|
||||
stream->pixm.plane_fmt[i].sizeimage);
|
||||
}
|
||||
vb_done->timestamp = ns_to_timeval(ktime_get_ns());
|
||||
vb_done->vb2_buf.timestamp = ktime_get_ns();
|
||||
vb2_buffer_done(&vb_done->vb2_buf, VB2_BUF_STATE_DONE);
|
||||
}
|
||||
|
||||
@@ -2097,7 +2090,7 @@ void rkcif_irq_pingpong(struct rkcif_device *cif_dev)
|
||||
/* TODO: xuhf-debug: add stream type */
|
||||
struct rkcif_stream *stream;
|
||||
void __iomem *base = cif_dev->base_addr;
|
||||
unsigned int intstat, i;
|
||||
unsigned int intstat, i = 0xff;
|
||||
|
||||
if (cif_dev->active_sensor->mbus.type == V4L2_MBUS_CSI2 &&
|
||||
cif_dev->chip_id == CHIP_RK1808_CIF) {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include <linux/regmap.h>
|
||||
#include <media/videobuf2-dma-contig.h>
|
||||
#include <media/v4l2-fwnode.h>
|
||||
#include <linux/dma-iommu.h>
|
||||
#include <linux/iommu.h>
|
||||
#include <dt-bindings/soc/rockchip-system-status.h>
|
||||
#include <soc/rockchip/rockchip-system-status.h>
|
||||
|
||||
@@ -234,7 +234,7 @@ static int rkcif_create_links(struct rkcif_device *dev)
|
||||
source_entity = &sensor->sd->entity;
|
||||
sink_entity = &dev->stream[RKCIF_STREAM_DVP].vnode.vdev.entity;
|
||||
|
||||
ret = media_entity_create_link(source_entity,
|
||||
ret = media_create_pad_link(source_entity,
|
||||
pad,
|
||||
sink_entity,
|
||||
0,
|
||||
@@ -252,7 +252,7 @@ static int rkcif_create_links(struct rkcif_device *dev)
|
||||
(dev->chip_id != CHIP_RK1808_CIF) | (id == pad - 1) ?
|
||||
(flags = MEDIA_LNK_FL_ENABLED) : (flags = 0);
|
||||
|
||||
ret = media_entity_create_link(source_entity,
|
||||
ret = media_create_pad_link(source_entity,
|
||||
pad,
|
||||
sink_entity,
|
||||
0,
|
||||
@@ -387,20 +387,19 @@ static int rkcif_register_platform_subdevs(struct rkcif_device *cif_dev)
|
||||
{
|
||||
int stream_num = 0, ret;
|
||||
|
||||
cif_dev->alloc_ctx = vb2_dma_contig_init_ctx(cif_dev->v4l2_dev.dev);
|
||||
|
||||
if (cif_dev->chip_id == CHIP_RK1808_CIF) {
|
||||
stream_num = RKCIF_MULTI_STREAMS_NUM;
|
||||
ret = rkcif_register_stream_vdevs(cif_dev, stream_num,
|
||||
true);
|
||||
if (ret < 0)
|
||||
goto err_cleanup_ctx;
|
||||
} else {
|
||||
stream_num = RKCIF_SINGLE_STREAM;
|
||||
ret = rkcif_register_stream_vdevs(cif_dev, stream_num,
|
||||
false);
|
||||
if (ret < 0)
|
||||
goto err_cleanup_ctx;
|
||||
}
|
||||
|
||||
if (ret < 0) {
|
||||
dev_err(cif_dev->dev, "cif register stream[%d] failed!\n", stream_num);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = cif_subdev_notifier(cif_dev);
|
||||
@@ -413,8 +412,6 @@ static int rkcif_register_platform_subdevs(struct rkcif_device *cif_dev)
|
||||
return 0;
|
||||
err_unreg_stream_vdev:
|
||||
rkcif_unregister_stream_vdevs(cif_dev, stream_num);
|
||||
err_cleanup_ctx:
|
||||
vb2_dma_contig_cleanup_ctx(cif_dev->alloc_ctx);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -585,61 +582,19 @@ err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int rkcif_iommu_init(struct rkcif_device *cif_dev)
|
||||
{
|
||||
struct iommu_group *group;
|
||||
int ret;
|
||||
|
||||
cif_dev->domain = iommu_domain_alloc(&platform_bus_type);
|
||||
if (!cif_dev->domain)
|
||||
return -ENOMEM;
|
||||
|
||||
ret = iommu_get_dma_cookie(cif_dev->domain);
|
||||
if (ret)
|
||||
goto err_free_domain;
|
||||
|
||||
group = iommu_group_get(cif_dev->dev);
|
||||
if (!group) {
|
||||
group = iommu_group_alloc();
|
||||
if (IS_ERR(group)) {
|
||||
ret = PTR_ERR(group);
|
||||
goto err_put_cookie;
|
||||
}
|
||||
ret = iommu_group_add_device(group, cif_dev->dev);
|
||||
iommu_group_put(group);
|
||||
if (ret)
|
||||
goto err_put_cookie;
|
||||
}
|
||||
iommu_group_put(group);
|
||||
|
||||
ret = iommu_attach_device(cif_dev->domain, cif_dev->dev);
|
||||
if (ret)
|
||||
goto err_put_cookie;
|
||||
if (!common_iommu_setup_dma_ops(cif_dev->dev, 0x10000000, SZ_2G,
|
||||
cif_dev->domain->ops)) {
|
||||
ret = -ENODEV;
|
||||
goto err_detach;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_detach:
|
||||
iommu_detach_device(cif_dev->domain, cif_dev->dev);
|
||||
err_put_cookie:
|
||||
iommu_put_dma_cookie(cif_dev->domain);
|
||||
err_free_domain:
|
||||
iommu_domain_free(cif_dev->domain);
|
||||
|
||||
dev_err(cif_dev->dev, "Failed to setup IOMMU, ret(%d)\n", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void rkcif_iommu_cleanup(struct rkcif_device *cif_dev)
|
||||
{
|
||||
iommu_detach_device(cif_dev->domain, cif_dev->dev);
|
||||
iommu_put_dma_cookie(cif_dev->domain);
|
||||
iommu_domain_free(cif_dev->domain);
|
||||
struct iommu_domain *domain;
|
||||
|
||||
dev_err(cif_dev->dev, "%s enter\n", __func__);
|
||||
|
||||
domain = iommu_get_domain_for_dev(cif_dev->dev);
|
||||
if (domain) {
|
||||
#ifdef CONFIG_IOMMU_API
|
||||
domain->ops->detach_dev(domain, cif_dev->dev);
|
||||
domain->ops->attach_dev(domain, cif_dev->dev);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool is_iommu_enable(struct device *dev)
|
||||
@@ -675,8 +630,6 @@ void rkcif_soft_reset(struct rkcif_device *cif_dev, bool is_rst_iommu)
|
||||
if (cif_dev->cif_rst[i])
|
||||
reset_control_deassert(cif_dev->cif_rst[i]);
|
||||
|
||||
if (cif_dev->iommu_en && is_rst_iommu)
|
||||
rkcif_iommu_init(cif_dev);
|
||||
}
|
||||
|
||||
static int rkcif_plat_probe(struct platform_device *pdev)
|
||||
@@ -816,9 +769,7 @@ static int rkcif_plat_probe(struct platform_device *pdev)
|
||||
goto err_unreg_media_dev;
|
||||
|
||||
cif_dev->iommu_en = is_iommu_enable(dev);
|
||||
if (cif_dev->iommu_en) {
|
||||
rkcif_iommu_init(cif_dev);
|
||||
} else {
|
||||
if (!cif_dev->iommu_en) {
|
||||
ret = of_reserved_mem_device_init(dev);
|
||||
if (ret)
|
||||
v4l2_warn(v4l2_dev,
|
||||
@@ -858,7 +809,6 @@ static int rkcif_plat_remove(struct platform_device *pdev)
|
||||
else
|
||||
stream_num = RKCIF_SINGLE_STREAM;
|
||||
rkcif_unregister_stream_vdevs(cif_dev, stream_num);
|
||||
vb2_dma_contig_cleanup_ctx(cif_dev->alloc_ctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ static int csi2_media_init(struct v4l2_subdev *sd)
|
||||
csi2->format_mbus.height = 1080;
|
||||
|
||||
v4l2_err(&csi2->sd, "media entry init\n");
|
||||
return media_entity_init(&sd->entity, num_pads, csi2->pad, 0);
|
||||
return media_entity_pads_init(&sd->entity, num_pads, csi2->pad);
|
||||
}
|
||||
|
||||
/* csi2 accepts all fmt/size from sensor */
|
||||
@@ -407,6 +407,7 @@ csi2_notifier_bound(struct v4l2_async_notifier *notifier,
|
||||
struct csi2_dev,
|
||||
notifier);
|
||||
struct csi2_sensor *sensor;
|
||||
struct media_link *link;
|
||||
unsigned int pad, ret;
|
||||
|
||||
if (csi2->num_sensors == ARRAY_SIZE(csi2->sensors))
|
||||
@@ -428,7 +429,7 @@ csi2_notifier_bound(struct v4l2_async_notifier *notifier,
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
ret = media_entity_create_link(&sensor->sd->entity, pad,
|
||||
ret = media_create_pad_link(&sensor->sd->entity, pad,
|
||||
&csi2->sd.entity, RK_CSI2_PAD_SINK,
|
||||
0/* csi2->num_sensors != 1 ? 0 : MEDIA_LNK_FL_ENABLED */);
|
||||
if (ret) {
|
||||
@@ -438,8 +439,8 @@ csi2_notifier_bound(struct v4l2_async_notifier *notifier,
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = media_entity_setup_link(csi2->sd.entity.links,
|
||||
MEDIA_LNK_FL_ENABLED);
|
||||
link = list_first_entry(&csi2->sd.entity.links, struct media_link, list);
|
||||
ret = media_entity_setup_link(link, MEDIA_LNK_FL_ENABLED);
|
||||
if (ret) {
|
||||
dev_err(csi2->dev,
|
||||
"failed to create link for %s\n",
|
||||
|
||||
Reference in New Issue
Block a user