Skip to content

Commit

Permalink
RS engineer release #4: support RS format (#81)
Browse files Browse the repository at this point in the history
Signed-off-by: zouxiaoh <xiaohong.zou@intel.com>
  • Loading branch information
zouxiaoh authored Jan 18, 2023
1 parent 1ef0278 commit 7a3d2d1
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 41 deletions.
5 changes: 3 additions & 2 deletions drivers/media/i2c/d4xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ static const struct ds5_resolution d46x_calibration_sizes[] = {

static const struct ds5_resolution ds5_size_imu[] = {
{
.width = 32,
.width = 32,
.height = 1,
.framerates = ds5_imu_framerates,
.n_framerates = ARRAY_SIZE(ds5_imu_framerates),
Expand Down Expand Up @@ -1181,6 +1181,7 @@ static unsigned int mbus_code_to_mipi(u32 code)
case MEDIA_BUS_FMT_SGRBG10_1X10:
case MEDIA_BUS_FMT_SRGGB10_1X10:
return MIPI_CSI2_TYPE_RAW10;
case MEDIA_BUS_FMT_Y8_1X8:
case MEDIA_BUS_FMT_SBGGR8_1X8:
case MEDIA_BUS_FMT_SGBRG8_1X8:
case MEDIA_BUS_FMT_SGRBG8_1X8:
Expand Down Expand Up @@ -4130,7 +4131,7 @@ static void ds5_substream_init(void)
set_sub_stream_dt(1, MIPI_CSI2_TYPE_EMBEDDED8);
set_sub_stream_vc_id(1, 0);

set_sub_stream_fmt(2, MEDIA_BUS_FMT_UYVY8_1X16);
set_sub_stream_fmt(2, MEDIA_BUS_FMT_YUYV8_1X16);
set_sub_stream_h(2, 640);
set_sub_stream_w(2, 480);
set_sub_stream_dt(2, mbus_code_to_mipi(MEDIA_BUS_FMT_UYVY8_1X16));
Expand Down
13 changes: 12 additions & 1 deletion drivers/media/i2c/ti960-des.c
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,8 @@ static int ti960_set_power(struct v4l2_subdev *subdev, int on)
if (ret || !on)
return ret;

/* Select TX port 0 R/W by default */
ret = ti960_reg_write(va, 0x32, 0x01);
/* Configure MIPI clock bsaed on control value. */
ret = ti960_reg_write(va, TI960_CSI_PLL_CTL,
ti960_op_sys_clock_reg_val[
Expand All @@ -830,8 +832,16 @@ static int ti960_set_power(struct v4l2_subdev *subdev, int on)
val = TI960_CSI_ENABLE;
val |= TI960_CSI_CONTS_CLOCK;
/* Enable skew calculation when 1.6Gbps output is enabled. */
if (v4l2_ctrl_g_ctrl(va->link_freq) == 3)
if (v4l2_ctrl_g_ctrl(va->link_freq) == 3) {
val |= TI960_CSI_SKEWCAL;
/* Enable periodic CSI-2 Skew-Calibration sequence after EOF */
ret = ti960_reg_write(va, TI960_CSI_CTL2, 0x09);
} else {
ret = ti960_reg_write(va, TI960_CSI_CTL2, 0x08);
}
if (ret)
return ret;

return ti960_reg_write(va, TI960_CSI_CTL, val);
}

Expand Down Expand Up @@ -1293,6 +1303,7 @@ static int ti960_register_subdev(struct ti960 *va)
va->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;

va->sd.internal_ops = &ti960_sd_internal_ops;
va->sd.entity.function = MEDIA_ENT_F_VID_MUX;

v4l2_set_subdevdata(&va->sd, client);

Expand Down
13 changes: 8 additions & 5 deletions drivers/media/i2c/ti960-reg.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@ static const struct ti960_register_write ti960_init_settings[] = {
{0xb2, 0x04},
{0xb1, 0x04},
{0xb2, 0x04},
{0x32, 0x01}, /* TX and FWD */
{0x33, 0x03},
{0x32, 0x12},
{0x33, 0x03},
{0x32, 0x12}, /* select TX1 R/W */
{0x33, 0x03}, /* CSI_ENABLE, CONTS_CLOCK */
{0x34, 0x08}, /* CSI_PASS_MODE all */
{0x32, 0x01}, /* select TX0 R/W */
{0x33, 0x03}, /* CSI_ENABLE, CONTS_CLOCK */
{0x34, 0x08}, /* CSI_PASS_MODE all */
{0x20, 0xf0},
{0x21, 0x03},
};
Expand All @@ -111,7 +113,8 @@ static const struct ti960_register_write ti960_init_settings[] = {
#define TI960_RAW12_ID 0x71
#define TI960_CSI_VC_MAP 0x72
#define TI960_PORT_CONFIG2 0x7c
#define TI960_CSI_CTL 0x33
#define TI960_CSI_CTL 0x33
#define TI960_CSI_CTL2 0x34

/* register value definition */
#define TI960_POWER_ON 0x1
Expand Down
4 changes: 3 additions & 1 deletion drivers/media/pci/intel/ipu-isys-csi2-be-soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ static const u32 csi2_be_soc_supported_codes_pad[] = {
MEDIA_BUS_FMT_SGBRG8_1X8,
MEDIA_BUS_FMT_SGRBG8_1X8,
MEDIA_BUS_FMT_SRGGB8_1X8,
MEDIA_BUS_FMT_Y8_1X8,
0,
};

Expand All @@ -57,6 +58,7 @@ static const u32 csi2_be_soc_supported_raw_bayer_codes_pad[] = {
MEDIA_BUS_FMT_SGBRG8_1X8,
MEDIA_BUS_FMT_SGRBG8_1X8,
MEDIA_BUS_FMT_SRGGB8_1X8,
MEDIA_BUS_FMT_Y8_1X8,
0,
};

Expand Down Expand Up @@ -255,7 +257,7 @@ static void csi2_be_soc_set_ffmt(struct v4l2_subdev *sd,
+ (idx & ~CSI2_BE_CROP_MASK)];

}
ffmt->code = code;
ffmt->code = fmt->format.code;
ffmt->width = r->width;
ffmt->height = r->height;
ffmt->field = sink_ffmt->field;
Expand Down
61 changes: 49 additions & 12 deletions drivers/media/pci/intel/ipu-isys-queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,16 +584,16 @@ static void __buf_queue(struct vb2_buffer *vb, bool force)
return;

if (!pipe_av || !vb->vb2_queue->streaming) {
dev_dbg(&av->isys->adev->dev,
"not pipe_av set, adding to incoming\n");
dev_info(&av->isys->adev->dev,
"no pipe or streaming, adding to incoming\n");
return;
}

mutex_unlock(&av->mutex);
mutex_lock(&pipe_av->mutex);

if (!force && ip->nr_streaming != ip->nr_queues) {
dev_dbg(&av->isys->adev->dev,
dev_info(&av->isys->adev->dev,
"not streaming yet, adding to incoming\n");
goto out;
}
Expand All @@ -607,10 +607,10 @@ static void __buf_queue(struct vb2_buffer *vb, bool force)
if (rval < 0) {
if (rval == -EINVAL) {
dev_err(&av->isys->adev->dev,
"error: should not happen\n");
"error: buffer list get failed\n");
WARN_ON(1);
} else {
dev_dbg(&av->isys->adev->dev,
dev_info(&av->isys->adev->dev,
"not enough buffers available\n");
}
goto out;
Expand All @@ -619,6 +619,8 @@ static void __buf_queue(struct vb2_buffer *vb, bool force)
msg = ipu_get_fw_msg_buf(ip);
if (!msg) {
rval = -ENOMEM;
dev_err(&av->isys->adev->dev,
"failed to get fw msg buf\n");
goto out;
}
buf = to_frame_msg_buf(msg);
Expand All @@ -629,7 +631,7 @@ static void __buf_queue(struct vb2_buffer *vb, bool force)
ip->nr_output_pins);

if (!ip->streaming) {
dev_dbg(&av->isys->adev->dev,
dev_info(&av->isys->adev->dev,
"got a buffer to start streaming!\n");
rval = ipu_isys_stream_start(ip, &bl, true);
if (rval)
Expand Down Expand Up @@ -811,15 +813,19 @@ static int __start_streaming(struct vb2_queue *q, unsigned int count)

if (first) {
rval = ipu_isys_video_prepare_streaming(av, 1);
if (rval)
if (rval) {
dev_err(&av->isys->adev->dev,
"%s: prepare stream: failed (%d)\n",
av->vdev.name, rval);
goto out_return_buffers;
}
}

mutex_unlock(&av->isys->stream_mutex);

rval = aq->link_fmt_validate(aq);
if (rval) {
dev_dbg(&av->isys->adev->dev,
dev_err(&av->isys->adev->dev,
"%s: link format validation failed (%d)\n",
av->vdev.name, rval);
goto out_unprepare_streaming;
Expand All @@ -836,24 +842,33 @@ static int __start_streaming(struct vb2_queue *q, unsigned int count)
dev_dbg(&av->isys->adev->dev, "queue %u of %u\n", ip->nr_streaming,
ip->nr_queues);
list_add(&aq->node, &ip->queues);
if (ip->nr_streaming != ip->nr_queues)
if (ip->nr_streaming != ip->nr_queues) {
dev_err(&av->isys->adev->dev,
"%s: streaming queue not match (%d)(%d)\n",
av->vdev.name, ip->nr_streaming, ip->nr_queues);
goto out;
}

if (list_empty(&av->isys->requests)) {
bl = &__bl;
rval = buffer_list_get(ip, bl);
if (rval == -EINVAL) {
dev_err(&av->isys->adev->dev,
"buffer list invalid\n");
goto out_stream_start;
} else if (rval < 0) {
dev_dbg(&av->isys->adev->dev,
dev_err(&av->isys->adev->dev,
"no request available, postponing streamon\n");
goto out;
}
}

rval = ipu_isys_stream_start(ip, bl, false);
if (rval)
if (rval) {
dev_err(&av->isys->adev->dev,
"isys stream start failed\n");
goto out_stream_start;
}

out:
if (pipe_av != av) {
Expand Down Expand Up @@ -948,6 +963,11 @@ static int reset_start_streaming(struct ipu_isys_video *av)

av->skipframe = 1;
rval = __start_streaming(&aq->vbq, 0);
if (rval) {
dev_dbg(&av->isys->adev->dev,
"%s: start streaming failed in reset\n",
av->vdev.name);
}

return rval;
}
Expand Down Expand Up @@ -1111,8 +1131,25 @@ static void stop_streaming(struct vb2_queue *q)
dev_dbg(&av->isys->adev->dev, "stop: %s: enter\n",
av->vdev.name);

if (!ip)
mutex_unlock(&av->mutex);
mutex_lock(&av->isys->reset_mutex);
while (av->isys->in_reset) {
mutex_unlock(&av->isys->reset_mutex);
dev_dbg(&av->isys->adev->dev, "stop: %s: wait for reset\n",
av->vdev.name
);
usleep_range(10000, 11000);
mutex_lock(&av->isys->reset_mutex);
}
mutex_unlock(&av->isys->reset_mutex);
mutex_lock(&av->mutex);

if (!ip) {
dev_err(&av->isys->adev->dev, "stop: %s: ip cleard!\n",
av->vdev.name);
return_buffers(aq, VB2_BUF_STATE_ERROR);
return;
}

mutex_lock(&av->isys->reset_mutex);
av->isys->in_stop_streaming = true;
Expand Down
34 changes: 24 additions & 10 deletions drivers/media/pci/intel/ipu-isys-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
const struct ipu_isys_pixelformat ipu_isys_pfmts_be_soc[] = {
{V4L2_PIX_FMT_Y10, 16, 10, 0, MEDIA_BUS_FMT_Y10_1X10,
IPU_FW_ISYS_FRAME_FORMAT_RAW16},
{V4L2_PIX_FMT_Y8I, 16, 16, 0, MEDIA_BUS_FMT_UYVY8_1X16,
IPU_FW_ISYS_FRAME_FORMAT_UYVY},
{V4L2_PIX_FMT_Z16, 16, 16, 0, MEDIA_BUS_FMT_UYVY8_1X16,
IPU_FW_ISYS_FRAME_FORMAT_UYVY},
{V4L2_PIX_FMT_UYVY, 16, 16, 0, MEDIA_BUS_FMT_UYVY8_1X16,
IPU_FW_ISYS_FRAME_FORMAT_UYVY},
{V4L2_PIX_FMT_YUYV, 16, 16, 0, MEDIA_BUS_FMT_YUYV8_1X16,
Expand Down Expand Up @@ -75,6 +79,8 @@ const struct ipu_isys_pixelformat ipu_isys_pfmts_be_soc[] = {
IPU_FW_ISYS_FRAME_FORMAT_RAW8},
{V4L2_PIX_FMT_SRGGB8, 8, 8, 0, MEDIA_BUS_FMT_SRGGB8_1X8,
IPU_FW_ISYS_FRAME_FORMAT_RAW8},
{V4L2_PIX_FMT_GREY, 8, 8, 0, MEDIA_BUS_FMT_Y8_1X8,
IPU_FW_ISYS_MIPI_DATA_TYPE_RAW_8},
{}
};

Expand All @@ -85,6 +91,10 @@ const struct ipu_isys_pixelformat ipu_isys_pfmts_packed[] = {
{V4L2_PIX_FMT_Y210, 20, 20, 0, MEDIA_BUS_FMT_YUYV10_1X20,
IPU_FW_ISYS_FRAME_FORMAT_YUYV},
#endif
{V4L2_PIX_FMT_Y8I, 16, 16, 0, MEDIA_BUS_FMT_UYVY8_1X16,
IPU_FW_ISYS_FRAME_FORMAT_UYVY},
{V4L2_PIX_FMT_Z16, 16, 16, 0, MEDIA_BUS_FMT_UYVY8_1X16,
IPU_FW_ISYS_FRAME_FORMAT_UYVY},
{V4L2_PIX_FMT_UYVY, 16, 16, 0, MEDIA_BUS_FMT_UYVY8_1X16,
IPU_FW_ISYS_FRAME_FORMAT_UYVY},
{V4L2_PIX_FMT_YUYV, 16, 16, 0, MEDIA_BUS_FMT_YUYV8_1X16,
Expand Down Expand Up @@ -120,6 +130,8 @@ const struct ipu_isys_pixelformat ipu_isys_pfmts_packed[] = {
IPU_FW_ISYS_FRAME_FORMAT_RAW10},
{V4L2_PIX_FMT_SRGGB10P, 10, 10, 0, MEDIA_BUS_FMT_SRGGB10_1X10,
IPU_FW_ISYS_FRAME_FORMAT_RAW10},
{V4L2_PIX_FMT_GREY, 8, 8, 0, MEDIA_BUS_FMT_Y8_1X8,
IPU_FW_ISYS_MIPI_DATA_TYPE_RAW_8},
{V4L2_PIX_FMT_SBGGR8, 8, 8, 0, MEDIA_BUS_FMT_SBGGR8_1X8,
IPU_FW_ISYS_FRAME_FORMAT_RAW8},
{V4L2_PIX_FMT_SGBRG8, 8, 8, 0, MEDIA_BUS_FMT_SGBRG8_1X8,
Expand Down Expand Up @@ -1462,13 +1474,12 @@ static int ipu_isys_query_sensor_info(struct media_pad *source_pad,
}

/* Get the sub stream info and set the current pipe's vc id */
for (i = CSI2_BE_SOC_PAD_SOURCE(0);
i < NR_OF_CSI2_BE_SOC_SOURCE_PADS; i++) {
for (i = 0; i < CSI2_BE_SOC_SOURCE_PADS_NUM; i++) {
/*
* index is sub stream id. sub stream id is
* equalto BE SOC source pad id - sink pad count
*/
qm.index = i - NR_OF_CSI2_BE_SOC_SINK_PADS;
qm.index = i;
ret = v4l2_querymenu(sd->ctrl_handler, &qm);
if (ret)
continue;
Expand Down Expand Up @@ -1576,11 +1587,10 @@ static int media_pipeline_walk_by_vc(struct ipu_isys_video *av,
continue;
}
pad_id = source_pad->index;
for (i = CSI2_BE_SOC_PAD_SOURCE(0);
i < NR_OF_CSI2_BE_SOC_SOURCE_PADS; i++) {
if (ip->asv[i - 1].substream ==
for (i = 0; i < CSI2_BE_SOC_SOURCE_PADS_NUM; i++) {
if (ip->asv[i].substream ==
(pad_id - NR_OF_CSI2_BE_SOC_SINK_PADS)) {
entity_vc = ip->asv[i - 1].vc;
entity_vc = ip->asv[i].vc;
break;
}
}
Expand Down Expand Up @@ -1748,12 +1758,14 @@ int ipu_isys_video_prepare_streaming(struct ipu_isys_video *av,
ip->interlaced = false;

rval = media_entity_enum_init(&ip->entity_enum, mdev);
if (rval)
if (rval) {
dev_err(dev, "entity enum init failed\n");
return rval;
}

rval = media_pipeline_start_by_vc(av, &ip->pipe);
if (rval < 0) {
dev_dbg(dev, "pipeline start failed\n");
dev_err(dev, "pipeline start failed\n");
goto out_enum_cleanup;
}

Expand All @@ -1764,8 +1776,10 @@ int ipu_isys_video_prepare_streaming(struct ipu_isys_video *av,
}

rval = media_graph_walk_init(&graph, mdev);
if (rval)
if (rval) {
dev_err(dev, "graph walk init failed\n");
goto out_pipeline_stop;
}

/* Gather all entities in the graph. */
mutex_lock(&mdev->graph_mutex);
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/pci/intel/ipu-isys.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ static int isys_fwnode_parse(struct device *dev,
return 0;
}

#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0)
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) && LINUX_VERSION_CODE != KERNEL_VERSION(5, 15, 71)
static int isys_notifier_init(struct ipu_isys *isys)
{
struct ipu_device *isp = isys->adev->isp;
Expand Down
Loading

0 comments on commit 7a3d2d1

Please sign in to comment.