static int lut_enum_mbus_code(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_mbus_code_enum *code) { static const unsigned int codes[] = { MEDIA_BUS_FMT_ARGB8888_1X32, MEDIA_BUS_FMT_AHSV8888_1X32, MEDIA_BUS_FMT_AYUV8_1X32, }; struct vsp1_lut *lut = to_lut(subdev); struct v4l2_mbus_framefmt *format; if (code->pad == LUT_PAD_SINK) { if (code->index >= ARRAY_SIZE(codes)) return -EINVAL; code->code = codes[code->index]; } else { /* The LUT can't perform format conversion, the sink format is * always identical to the source format. */ if (code->index) return -EINVAL; format = vsp1_entity_get_pad_format(&lut->entity, cfg, LUT_PAD_SINK, code->which); code->code = format->code; } return 0; }
static int lut_enum_frame_size(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_frame_size_enum *fse) { struct vsp1_lut *lut = to_lut(subdev); struct v4l2_mbus_framefmt *format; format = vsp1_entity_get_pad_format(&lut->entity, cfg, fse->pad, fse->which); if (fse->index || fse->code != format->code) return -EINVAL; if (fse->pad == LUT_PAD_SINK) { fse->min_width = LUT_MIN_SIZE; fse->max_width = LUT_MAX_SIZE; fse->min_height = LUT_MIN_SIZE; fse->max_height = LUT_MAX_SIZE; } else { /* The size on the source pad are fixed and always identical to * the size on the sink pad. */ fse->min_width = format->width; fse->max_width = format->width; fse->min_height = format->height; fse->max_height = format->height; } return 0; }
static void lut_configure(struct vsp1_entity *entity, struct vsp1_pipeline *pipe, struct vsp1_dl_list *dl, enum vsp1_entity_params params) { struct vsp1_lut *lut = to_lut(&entity->subdev); struct vsp1_dl_body *dlb; unsigned long flags; switch (params) { case VSP1_ENTITY_PARAMS_INIT: vsp1_lut_write(lut, dl, VI6_LUT_CTRL, VI6_LUT_CTRL_EN); break; case VSP1_ENTITY_PARAMS_PARTITION: break; case VSP1_ENTITY_PARAMS_RUNTIME: spin_lock_irqsave(&lut->lock, flags); dlb = lut->lut; lut->lut = NULL; spin_unlock_irqrestore(&lut->lock, flags); if (dlb) vsp1_dl_list_add_fragment(dl, dlb); break; } }
static int lut_get_format(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *fmt) { struct vsp1_lut *lut = to_lut(subdev); fmt->format = *vsp1_entity_get_pad_format(&lut->entity, cfg, fmt->pad, fmt->which); return 0; }
static int lut_s_stream(struct v4l2_subdev *subdev, int enable) { struct vsp1_lut *lut = to_lut(subdev); if (!enable) return 0; vsp1_lut_write(lut, VI6_LUT_CTRL, VI6_LUT_CTRL_EN); return 0; }
static long lut_ioctl(struct v4l2_subdev *subdev, unsigned int cmd, void *arg) { struct vsp1_lut *lut = to_lut(subdev); switch (cmd) { case VIDIOC_VSP1_LUT_CONFIG: return lut_set_table(lut, arg); default: return -ENOIOCTLCMD; } }
static int lut_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *fmt) { struct vsp1_lut *lut = to_lut(subdev); struct v4l2_subdev_pad_config *config; struct v4l2_mbus_framefmt *format; int ret = 0; mutex_lock(&lut->entity.lock); config = vsp1_entity_get_pad_config(&lut->entity, cfg, fmt->which); if (!config) { ret = -EINVAL; goto done; } /* Default to YUV if the requested format is not supported. */ if (fmt->format.code != MEDIA_BUS_FMT_ARGB8888_1X32 && fmt->format.code != MEDIA_BUS_FMT_AHSV8888_1X32 && fmt->format.code != MEDIA_BUS_FMT_AYUV8_1X32) fmt->format.code = MEDIA_BUS_FMT_AYUV8_1X32; format = vsp1_entity_get_pad_format(&lut->entity, config, fmt->pad); if (fmt->pad == LUT_PAD_SOURCE) { /* The LUT output format can't be modified. */ fmt->format = *format; goto done; } format->code = fmt->format.code; format->width = clamp_t(unsigned int, fmt->format.width, LUT_MIN_SIZE, LUT_MAX_SIZE); format->height = clamp_t(unsigned int, fmt->format.height, LUT_MIN_SIZE, LUT_MAX_SIZE); format->field = V4L2_FIELD_NONE; format->colorspace = V4L2_COLORSPACE_SRGB; fmt->format = *format; /* Propagate the format to the source pad. */ format = vsp1_entity_get_pad_format(&lut->entity, config, LUT_PAD_SOURCE); *format = fmt->format; done: mutex_unlock(&lut->entity.lock); return ret; }
static void lut_configure(struct vsp1_entity *entity, struct vsp1_pipeline *pipe, struct vsp1_dl_list *dl) { struct vsp1_lut *lut = to_lut(&entity->subdev); vsp1_lut_write(lut, dl, VI6_LUT_CTRL, VI6_LUT_CTRL_EN); mutex_lock(&lut->lock); if (lut->lut) { vsp1_dl_list_add_fragment(dl, lut->lut); lut->lut = NULL; } mutex_unlock(&lut->lock); }
static void lut_configure(struct vsp1_entity *entity, struct vsp1_pipeline *pipe, struct vsp1_dl_list *dl, bool full) { struct vsp1_lut *lut = to_lut(&entity->subdev); struct vsp1_dl_body *dlb; unsigned long flags; if (full) { vsp1_lut_write(lut, dl, VI6_LUT_CTRL, VI6_LUT_CTRL_EN); return; } spin_lock_irqsave(&lut->lock, flags); dlb = lut->lut; lut->lut = NULL; spin_unlock_irqrestore(&lut->lock, flags); if (dlb) vsp1_dl_list_add_fragment(dl, dlb); }