[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190807153646.GO21370@paasikivi.fi.intel.com>
Date: Wed, 7 Aug 2019 18:36:46 +0300
From: Sakari Ailus <sakari.ailus@...ux.intel.com>
To: Helen Koike <helen.koike@...labora.com>
Cc: linux-rockchip@...ts.infradead.org, devicetree@...r.kernel.org,
eddie.cai.linux@...il.com, mchehab@...nel.org, heiko@...ech.de,
jacob2.chen@...k-chips.com, jeffy.chen@...k-chips.com,
zyc@...k-chips.com, linux-kernel@...r.kernel.org,
tfiga@...omium.org, hans.verkuil@...co.com,
laurent.pinchart@...asonboard.com, kernel@...labora.com,
ezequiel@...labora.com, linux-media@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, zhengsq@...k-chips.com,
Jacob Chen <cc@...k-chips.com>,
Allon Huang <allon.huang@...k-chips.com>
Subject: Re: [PATCH v8 09/14] media: rkisp1: add rockchip isp1 core driver
Hi Helen,
On Tue, Jul 30, 2019 at 03:42:51PM -0300, Helen Koike wrote:
...
> +static int rkisp1_fwnode_parse(struct device *dev,
> + struct v4l2_fwnode_endpoint *vep,
> + struct v4l2_async_subdev *asd)
> +{
> + struct sensor_async_subdev *s_asd =
> + container_of(asd, struct sensor_async_subdev, asd);
> +
> + if (vep->bus_type != V4L2_MBUS_CSI2_DPHY) {
> + dev_err(dev, "Only CSI2 bus type is currently supported\n");
> + return -EINVAL;
> + }
> +
> + if (vep->base.port != 0) {
> + dev_err(dev, "The ISP has only port 0\n");
> + return -EINVAL;
> + }
> +
> + s_asd->mbus.type = vep->bus_type;
> + s_asd->mbus.flags = vep->bus.mipi_csi2.flags;
> + s_asd->lanes = vep->bus.mipi_csi2.num_data_lanes;
> +
> + switch (vep->bus.mipi_csi2.num_data_lanes) {
> + case 1:
> + s_asd->mbus.flags |= V4L2_MBUS_CSI2_1_LANE;
> + break;
> + case 2:
> + s_asd->mbus.flags |= V4L2_MBUS_CSI2_2_LANE;
> + break;
> + case 3:
> + s_asd->mbus.flags |= V4L2_MBUS_CSI2_3_LANE;
> + break;
> + case 4:
> + s_asd->mbus.flags |= V4L2_MBUS_CSI2_4_LANE;
> + break;
Could you use struct v4l2_fwnode_endpoint directly? The mbus config is a
legacy struct from bygone times and I'd like to avoid using it in new
drivers.
> + default:
> + return -EINVAL;
> + }
> +
> + return 0;
> +}
> +
> +static const struct v4l2_async_notifier_operations subdev_notifier_ops = {
> + .bound = subdev_notifier_bound,
> + .unbind = subdev_notifier_unbind,
> + .complete = subdev_notifier_complete,
> +};
> +
> +static int isp_subdev_notifier(struct rkisp1_device *isp_dev)
> +{
> + struct v4l2_async_notifier *ntf = &isp_dev->notifier;
> + struct device *dev = isp_dev->dev;
> + int ret;
> +
> + v4l2_async_notifier_init(ntf);
> +
> + ret = v4l2_async_notifier_parse_fwnode_endpoints_by_port(
> + dev, ntf, sizeof(struct sensor_async_subdev), 0,
> + rkisp1_fwnode_parse);
I know these functions aren't old but there's a better alternative. See
e.g. isp_parse_of_endpoints in drivers/media/platform/omap3isp/isp.c or
cio2_parse_firmware in drivers/media/pci/intel/ipu3/ipu3-cio2.c.
> + if (ret < 0)
> + return ret;
> +
> + if (list_empty(&ntf->asd_list))
> + return -ENODEV; /* no endpoint */
> +
> + ntf->ops = &subdev_notifier_ops;
> +
> + return v4l2_async_notifier_register(&isp_dev->v4l2_dev, ntf);
> +}
--
Sakari Ailus
sakari.ailus@...ux.intel.com
Powered by blists - more mailing lists