static int mxr_try_format(struct mxr_device *mdev, struct v4l2_subdev_fh *fh, u32 pad, struct v4l2_mbus_framefmt *fmt, enum v4l2_subdev_format_whence which) { struct v4l2_mbus_framefmt mbus_fmt; fmt->width = clamp_val(fmt->width, 1, 32767); fmt->height = clamp_val(fmt->height, 1, 2047); switch (pad) { case MXR_PAD_SINK_GSCALER: fmt->code = V4L2_MBUS_FMT_YUV8_1X24; break; case MXR_PAD_SINK_GRP0: case MXR_PAD_SINK_GRP1: fmt->code = mxr_adjust_graph_format(fmt->code); break; case MXR_PAD_SOURCE_GSCALER: case MXR_PAD_SOURCE_GRP0: case MXR_PAD_SOURCE_GRP1: mxr_get_mbus_fmt(mdev, &mbus_fmt); fmt->code = (fmt->code == V4L2_MBUS_FMT_YUV8_1X24) ? V4L2_MBUS_FMT_YUV8_1X24 : V4L2_MBUS_FMT_XRGB8888_4X8_LE; fmt->width = mbus_fmt.width; fmt->height = mbus_fmt.height; break; } return 0; }
/*set mixer resolution */ void mxr_reg_set_resolution(struct mxr_device *mdev) { u32 mxr_wh; struct v4l2_mbus_framefmt mbus_fmt; mxr_get_mbus_fmt(mdev, &mbus_fmt); mxr_wh = MXR_RESOLUTION_WIDTH(mbus_fmt.width); mxr_wh |= MXR_RESOLUTION_HEIGHT(mbus_fmt.height); mxr_write(mdev, MXR_RESOLUTION, mxr_wh); }
/* Geometry handling */ void mxr_layer_geo_fix(struct mxr_layer *layer) { struct mxr_device *mdev = layer->mdev; struct v4l2_mbus_framefmt mbus_fmt; /* TODO: add some dirty flag to avoid unnecessary adjustments */ mxr_get_mbus_fmt(mdev, &mbus_fmt); layer->geo.dst.full_width = mbus_fmt.width; layer->geo.dst.full_height = mbus_fmt.height; layer->geo.dst.field = mbus_fmt.field; layer->ops.fix_geometry(layer); }
void mxr_layer_default_geo(struct mxr_layer *layer) { struct mxr_device *mdev = layer->mdev; struct v4l2_mbus_framefmt mbus_fmt; mxr_dbg(layer->mdev, "%s start\n", __func__); memset(&layer->geo, 0, sizeof layer->geo); mxr_get_mbus_fmt(mdev, &mbus_fmt); layer->geo.dst.full_width = mbus_fmt.width; layer->geo.dst.full_height = mbus_fmt.height; layer->geo.dst.width = layer->geo.dst.full_width; layer->geo.dst.height = layer->geo.dst.full_height; layer->geo.dst.field = mbus_fmt.field; layer->geo.src.full_width = mbus_fmt.width; layer->geo.src.full_height = mbus_fmt.height; layer->geo.src.width = layer->geo.src.full_width; layer->geo.src.height = layer->geo.src.full_height; layer->ops.fix_geometry(layer); }