#include <linux/slab.h>
#include <linux/smiapp.h>
#include <linux/v4l2-mediabus.h>
+#include <media/mipi-csi2.h>
#include <media/v4l2-cci.h>
#include <media/v4l2-device.h>
#include <media/v4l2-fwnode.h>
return ret;
}
+static u8 ccs_mipi_csi2_data_type(unsigned int bpp)
+{
+ switch (bpp) {
+ case 6:
+ return MIPI_CSI2_DT_RAW6;
+ case 7:
+ return MIPI_CSI2_DT_RAW7;
+ case 8:
+ return MIPI_CSI2_DT_RAW8;
+ case 10:
+ return MIPI_CSI2_DT_RAW10;
+ case 12:
+ return MIPI_CSI2_DT_RAW12;
+ case 14:
+ return MIPI_CSI2_DT_RAW14;
+ case 16:
+ return MIPI_CSI2_DT_RAW16;
+ case 20:
+ return MIPI_CSI2_DT_RAW20;
+ case 24:
+ return MIPI_CSI2_DT_RAW24;
+ default:
+ WARN_ON(1);
+ return 0;
+ }
+}
+
static int ccs_read_frame_fmt(struct ccs_sensor *sensor)
{
struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
if (crops)
for (i = 0; i < subdev->entity.num_pads; i++)
crops[i] =
- v4l2_subdev_state_get_crop(sd_state, i);
+ v4l2_subdev_state_get_crop(sd_state, i,
+ CCS_STREAM_PIXEL);
if (comps)
- *comps = v4l2_subdev_state_get_compose(sd_state,
- ssd->sink_pad);
+ *comps = v4l2_subdev_state_get_compose(sd_state, ssd->sink_pad,
+ CCS_STREAM_PIXEL);
}
/* Changes require propagation only on sink pad. */
fallthrough;
case V4L2_SEL_TGT_COMPOSE:
*crops[CCS_PAD_SRC] = *comp;
- fmt = v4l2_subdev_state_get_format(sd_state, CCS_PAD_SRC);
+ fmt = v4l2_subdev_state_get_format(sd_state, CCS_PAD_SRC,
+ CCS_STREAM_PIXEL);
fmt->width = comp->width;
fmt->height = comp->height;
if (which == V4L2_SUBDEV_FORMAT_ACTIVE && ssd == sensor->src)
return ret;
}
+static int ccs_get_frame_desc(struct v4l2_subdev *subdev, unsigned int pad,
+ struct v4l2_mbus_frame_desc *desc)
+{
+ struct ccs_sensor *sensor = to_ccs_sensor(subdev);
+ struct v4l2_mbus_frame_desc_entry *entry = desc->entry;
+ struct v4l2_subdev_state *sd_state;
+
+ switch (sensor->hwcfg.csi_signalling_mode) {
+ case CCS_CSI_SIGNALING_MODE_CSI_2_DPHY:
+ case CCS_CSI_SIGNALING_MODE_CSI_2_CPHY:
+ desc->type = V4L2_MBUS_FRAME_DESC_TYPE_CSI2;
+ break;
+ default:
+ /* FIXME: CCP2 support */
+ return -EINVAL;
+ }
+
+ sd_state = v4l2_subdev_lock_and_get_active_state(subdev);
+ if (!sd_state)
+ return -EINVAL;
+
+ entry->pixelcode = sensor->csi_format->code;
+ entry->stream = CCS_STREAM_PIXEL;
+ entry->bus.csi2.dt =
+ sensor->csi_format->width == sensor->csi_format->compressed ?
+ ccs_mipi_csi2_data_type(sensor->csi_format->width) :
+ CCS_DEFAULT_COMPRESSED_DT;
+ entry++;
+ desc->num_entries++;
+
+ v4l2_subdev_unlock_state(sd_state);
+
+ return 0;
+}
+
static int ccs_get_skip_frames(struct v4l2_subdev *subdev, u32 *frames)
{
struct ccs_sensor *sensor = to_ccs_sensor(subdev);
.set_selection = ccs_set_selection,
.enable_streams = ccs_enable_streams,
.disable_streams = ccs_disable_streams,
+ .get_frame_desc = ccs_get_frame_desc,
};
static const struct v4l2_subdev_sensor_ops ccs_sensor_ops = {