"\t\t bit 0=crop, 1=compose, 2=scale,\n"
"\t\t -1=user-controlled (default)");
-static unsigned
-multiplanar[VIVID_MAX_DEVS] = { [0 ... (VIVID_MAX_DEVS - 1)] = 2 };
+static unsigned multiplanar[VIVID_MAX_DEVS] = { [0 ... (VIVID_MAX_DEVS - 1)] = 1 };
module_param_array(multiplanar, uint, NULL, 0444);
MODULE_PARM_DESC(multiplanar, " 1 (default) creates a single planar device, 2 creates a multiplanar device.");
/* Default: video + vbi-cap (raw and sliced) + radio rx + radio tx + sdr + vbi-out + vid-out */
-/* Expose only video capture and video output nodes for the current test pipeline */
-static unsigned node_types[VIVID_MAX_DEVS] = { [0 ... (VIVID_MAX_DEVS - 1)] = 0x0101 };
+static unsigned node_types[VIVID_MAX_DEVS] = { [0 ... (VIVID_MAX_DEVS - 1)] = 0x1d3d };
module_param_array(node_types, uint, NULL, 0444);
MODULE_PARM_DESC(node_types, " node types, default is 0x1d3d. Bitmask with the following meaning:\n"
"\t\t bit 0: Video Capture node\n"
"\t\t bit 16: Framebuffer for testing overlays");
/* Default: 4 inputs */
-/* Force to have only one input for current test pipeline */
-static unsigned num_inputs[VIVID_MAX_DEVS] = { [0 ... (VIVID_MAX_DEVS - 1)] = 1 };
+static unsigned num_inputs[VIVID_MAX_DEVS] = { [0 ... (VIVID_MAX_DEVS - 1)] = 4 };
module_param_array(num_inputs, uint, NULL, 0444);
MODULE_PARM_DESC(num_inputs, " number of inputs, default is 4");
/* Default: input 0 = WEBCAM, 1 = TV, 2 = SVID, 3 = HDMI */
-/* support only HDMI input type for current test pipeline */
-static unsigned input_types[VIVID_MAX_DEVS] = { [0 ... (VIVID_MAX_DEVS - 1)] = 0x03 };
+static unsigned input_types[VIVID_MAX_DEVS] = { [0 ... (VIVID_MAX_DEVS - 1)] = 0xe4 };
module_param_array(input_types, uint, NULL, 0444);
MODULE_PARM_DESC(input_types, " input types, default is 0xe4. Two bits per input,\n"
"\t\t bits 0-1 == input 0, bits 31-30 == input 15.\n"
"\t\t Type 0 == webcam, 1 == TV, 2 == S-Video, 3 == HDMI");
/* Default: 2 outputs */
-/* Force to have only one output for current test pipeline */
-static unsigned num_outputs[VIVID_MAX_DEVS] = { [0 ... (VIVID_MAX_DEVS - 1)] = 1 };
+static unsigned num_outputs[VIVID_MAX_DEVS] = { [0 ... (VIVID_MAX_DEVS - 1)] = 2 };
module_param_array(num_outputs, uint, NULL, 0444);
MODULE_PARM_DESC(num_outputs, " number of outputs, default is 2");
/* Default: output 0 = SVID, 1 = HDMI */
-/* support only HDMI output type for current test pipeline */
-static unsigned output_types[VIVID_MAX_DEVS] = { [0 ... (VIVID_MAX_DEVS - 1)] = 0x01 };
+static unsigned output_types[VIVID_MAX_DEVS] = { [0 ... (VIVID_MAX_DEVS - 1)] = 2 };
module_param_array(output_types, uint, NULL, 0444);
MODULE_PARM_DESC(output_types, " output types, default is 0x02. One bit per output,\n"
"\t\t bit 0 == output 0, bit 15 == output 15.\n"
struct video_device *vdev = video_devdata(file);
strcpy(cap->driver, "vivid");
- snprintf(cap->card, sizeof(cap->card),
- "%s", dev->v4l2_dev.name);
+ strcpy(cap->card, "vivid");
snprintf(cap->bus_info, sizeof(cap->bus_info),
"platform:%s", dev->v4l2_dev.name);
kfree(dev);
}
-static int vivid_parse_dt(struct video_device *vfd, struct vivid_dev *dev)
-{
- struct device_node *vivid_node = NULL;
- struct device_node *node = NULL;
- char temp_str[OF_MAX_STR_LEN];
-
- vivid_node = of_find_node_by_name(NULL, "vivid-driver");
- if (!vivid_node) {
- dev_err(&vfd->dev, "%s:cannot find vivid node\n", __func__);
- return -ENODATA;
- }
-
- snprintf(temp_str, sizeof(temp_str), "%s%d", "instance", dev->inst);
- node = of_find_node_by_name(vivid_node, temp_str);
- if (!node) {
- dev_err(&vfd->dev, "%s:cannot find instance node\n", __func__);
- return -ENODATA;
- }
-
- sensor_common_init_sensor_properties(&vfd->dev,
- node, &dev->sensor_props);
-
- v4l2_ctrl_s_ctrl(dev->ctrl_sensormodes, dev->sensor_props.num_modes);
-
- vivid_update_sensorprops(dev);
-
- return 0;
-}
-
static int vivid_create_instance(struct platform_device *pdev, int inst)
{
static const struct v4l2_dv_timings def_dv_timings =
dev->fmt_out = &vivid_formats[0];
if (!dev->multiplanar)
vivid_formats[0].data_offset[0] = 0;
- dev->embedded_data_height = DEF_METADATA_HEIGHT;
- dev->fmt_out_metadata_height = DEF_METADATA_HEIGHT;
dev->webcam_size_idx = 1;
dev->webcam_ival_idx = 3;
- tpg_s_fourcc(&dev->tpg, dev->fmt_cap->fourcc, DEF_METADATA_HEIGHT);
+ tpg_s_fourcc(&dev->tpg, dev->fmt_cap->fourcc);
dev->std_cap = V4L2_STD_PAL;
dev->std_out = V4L2_STD_PAL;
if (dev->input_type[0] == TV || dev->input_type[0] == SVID)
memcpy(dev->edid, vivid_hdmi_edid, sizeof(vivid_hdmi_edid));
ktime_get_ts(&dev->radio_rds_init_ts);
- /* initialize locks */
- spin_lock_init(&dev->slock);
- mutex_init(&dev->mutex);
- mutex_init(&dev->mutex_framerate);
-
/* create all controls */
ret = vivid_create_controls(dev, ccs_cap == -1, ccs_out == -1, no_error_inj,
in_type_counter[TV] || in_type_counter[SVID] ||
dev->fb_cap.fmt.bytesperline = dev->src_rect.width * tpg_g_twopixelsize(&dev->tpg, 0) / 2;
dev->fb_cap.fmt.sizeimage = dev->src_rect.height * dev->fb_cap.fmt.bytesperline;
+ /* initialize locks */
+ spin_lock_init(&dev->slock);
+ mutex_init(&dev->mutex);
+
/* init dma queues */
INIT_LIST_HEAD(&dev->vid_cap_active);
INIT_LIST_HEAD(&dev->vid_out_active);
goto unreg_dev;
v4l2_info(&dev->v4l2_dev, "V4L2 capture device registered as %s\n",
video_device_node_name(vfd));
-
- ret = vivid_parse_dt(vfd, dev);
- if (ret < 0)
- goto unreg_dev;
}
if (dev->has_vid_out) {
#include <media/v4l2-device.h>
#include <media/v4l2-dev.h>
#include <media/v4l2-ctrls.h>
-#include <media/sensor_common.h>
#include "vivid-tpg.h"
#include "vivid-rds-gen.h"
#include "vivid-vbi-gen.h"
/* The minimum image width/height */
#define MIN_WIDTH 16
#define MIN_HEIGHT 16
-/* Metadata height max/default */
-#define MAX_METADATA_HEIGHT 16
-#define DEF_METADATA_HEIGHT 1
/* The data_offset of plane 0 for the multiplanar formats */
#define PLANE0_DATA_OFFSET 128
u32 fourcc; /* v4l2 format id */
bool is_yuv;
bool can_do_overlay;
- bool is_metadata[TPG_MAX_PLANES];
u8 vdownsampling[TPG_MAX_PLANES];
- u8 packedpixels;
u32 alpha_mask;
u8 planes;
u8 buffers;
struct v4l2_ctrl_handler ctrl_hdl_sdr_cap;
spinlock_t slock;
struct mutex mutex;
- struct mutex mutex_framerate;
/* capabilities */
u32 vid_cap_caps;
struct v4l2_ctrl *colorspace;
struct v4l2_ctrl *rgb_range_cap;
struct v4l2_ctrl *real_rgb_range_cap;
- struct v4l2_ctrl *framelength;
- struct v4l2_ctrl *ctrl_signalprops;
- struct v4l2_ctrl *ctrl_imageprops;
- struct v4l2_ctrl *ctrl_controlprops;
- struct v4l2_ctrl *ctrl_dvtimings;
- struct v4l2_ctrl *ctrl_sensormodes;
struct {
/* std_signal_mode/standard cluster */
struct v4l2_ctrl *ctrl_std_signal_mode;
u32 xfer_func_out;
u32 service_set_out;
unsigned bytesperline_out[TPG_MAX_PLANES];
- unsigned height_out[TPG_MAX_PLANES];
unsigned tv_field_out;
unsigned tv_audio_output;
bool vbi_out_have_wss;
unsigned ms_vid_cap;
bool must_blank[VIDEO_MAX_FRAME];
- struct vivid_fmt *fmt_cap;
+ const struct vivid_fmt *fmt_cap;
struct v4l2_fract timeperframe_vid_cap;
enum v4l2_field field_cap;
struct v4l2_rect src_rect;
u32 vbi_cap_seq_count;
bool vbi_cap_streaming;
bool stream_sliced_vbi_cap;
- u32 embedded_data_height;
- u32 fmt_out_metadata_height;
-
- /* added for NV sensor emulation */
- struct sensor_properties sensor_props;
/* video output */
- struct vivid_fmt *fmt_out;
+ const struct vivid_fmt *fmt_out;
struct v4l2_fract timeperframe_vid_out;
enum v4l2_field field_out;
struct v4l2_rect sink_rect;
#define VIVID_CID_SDR_CAP_FM_DEVIATION (VIVID_CID_VIVID_BASE + 110)
-#define VIVID_CID_COARSE_TIME (VIVID_CID_VIVID_BASE + 120)
-#define VIVID_CID_COARSE_TIME_SHORT (VIVID_CID_VIVID_BASE + 121)
-#define VIVID_CID_FRAME_LENGTH (VIVID_CID_VIVID_BASE + 122)
-#define VIVID_CID_GROUP_HOLD (VIVID_CID_VIVID_BASE + 123)
-#define VIVID_CID_HDR_EN (VIVID_CID_VIVID_BASE + 124)
-#define VIVID_CID_SENSOR_SIGNAL_PROPERTIES (VIVID_CID_VIVID_BASE + 125)
-#define VIVID_CID_SENSOR_IMAGE_PROPERTIES (VIVID_CID_VIVID_BASE + 126)
-#define VIVID_CID_SENSOR_CONTROL_PROPERTIES (VIVID_CID_VIVID_BASE + 127)
-#define VIVID_CID_SENSOR_DV_TIMINGS (VIVID_CID_VIVID_BASE + 128)
-/**
- * This is temporary with the current v4l2 infrastructure
- * currently discussing with upstream maintainers our proposals and
- * better approaches to resolve this
- */
-#define VIVID_CID_SENSOR_MODES (VIVID_CID_VIVID_BASE + 129)
-
/* General User Controls */
static int vivid_user_gen_s_ctrl(struct v4l2_ctrl *ctrl)
.type = V4L2_CTRL_TYPE_BUTTON,
};
+
/* Video User Controls */
static int vivid_user_vid_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
if (dev->edid_blocks > dev->edid_max_blocks)
dev->edid_blocks = dev->edid_max_blocks;
break;
- case VIVID_CID_FRAME_LENGTH:
- vivid_update_timeperframe(dev, ctrl->val);
- break;
- }
- return 0;
-}
-
-int vivid_update_sensorprops(struct vivid_dev *dev)
-{
- struct v4l2_ctrl *ctrl_signalprops = dev->ctrl_signalprops;
- struct v4l2_ctrl *ctrl_imageprops = dev->ctrl_imageprops;
- struct v4l2_ctrl *ctrl_controlprops = dev->ctrl_controlprops;
- struct v4l2_ctrl *ctrl_dvtimings = dev->ctrl_dvtimings;
- struct sensor_mode_properties *modes = dev->sensor_props.sensor_modes;
- u32 i;
-
- for (i = 0; i < dev->sensor_props.num_modes; i++) {
- void *ptr = NULL;
- u32 size = sizeof(struct sensor_signal_properties);
-
- ptr = ctrl_signalprops->p_new.p + (i * size);
- memcpy(ptr, &modes[i].signal_properties, size);
-
- size = sizeof(struct sensor_image_properties);
- ptr = ctrl_imageprops->p_new.p + (i * size);
- memcpy(ptr, &modes[i].image_properties, size);
-
- size = sizeof(struct sensor_control_properties);
- ptr = ctrl_controlprops->p_new.p + (i * size);
- memcpy(ptr, &modes[i].control_properties, size);
-
- size = sizeof(struct sensor_dv_timings);
- ptr = ctrl_dvtimings->p_new.p + (i * size);
- memcpy(ptr, &modes[i].dv_timings, size);
}
- ctrl_signalprops->p_cur.p = ctrl_signalprops->p_new.p;
- ctrl_imageprops->p_cur.p = ctrl_imageprops->p_new.p;
- ctrl_controlprops->p_cur.p = ctrl_controlprops->p_new.p;
- ctrl_dvtimings->p_cur.p = ctrl_dvtimings->p_new.p;
-
return 0;
}
.s_ctrl = vivid_vid_cap_s_ctrl,
};
-#define MIN_FRAME_LENGTH 0x0
-#define MAX_FRAME_LENGTH 0x7FFF
-#define DEF_FRAME_LENGTH 0x07C0
-#define MIN_EXPOSURE_COARSE 0x0002
-#define MAX_EXPOSURE_COARSE 0x7FF8
-#define DEF_EXPOSURE_COARSE 0x07B8
-
-static const struct v4l2_ctrl_config vivid_ctrl_framelength = {
- .ops = &vivid_vid_cap_ctrl_ops,
- .id = VIVID_CID_FRAME_LENGTH,
- .name = "Frame Length",
- .type = V4L2_CTRL_TYPE_INTEGER,
- .flags = V4L2_CTRL_FLAG_SLIDER,
- .min = MIN_FRAME_LENGTH,
- .max = MAX_FRAME_LENGTH,
- .def = DEF_FRAME_LENGTH,
- .step = 1,
-};
-
-static const struct v4l2_ctrl_config vivid_ctrl_coarsetime = {
- .ops = &vivid_vid_cap_ctrl_ops,
- .id = VIVID_CID_COARSE_TIME,
- .name = "Coarse Time",
- .type = V4L2_CTRL_TYPE_INTEGER,
- .flags = V4L2_CTRL_FLAG_SLIDER,
- .min = MIN_EXPOSURE_COARSE,
- .max = MAX_EXPOSURE_COARSE,
- .def = DEF_EXPOSURE_COARSE,
- .step = 1,
-};
-
-static const struct v4l2_ctrl_config vivid_ctrl_coarsetime_short = {
- .ops = &vivid_vid_cap_ctrl_ops,
- .id = VIVID_CID_COARSE_TIME_SHORT,
- .name = "Coarse Time Short",
- .type = V4L2_CTRL_TYPE_INTEGER,
- .flags = V4L2_CTRL_FLAG_SLIDER,
- .min = MIN_EXPOSURE_COARSE,
- .max = MAX_EXPOSURE_COARSE,
- .def = DEF_EXPOSURE_COARSE,
- .step = 1,
-};
-
-static const struct v4l2_ctrl_config vivid_ctrl_grouphold = {
- .ops = &vivid_vid_cap_ctrl_ops,
- .id = VIVID_CID_GROUP_HOLD,
- .name = "Group Hold",
- .type = V4L2_CTRL_TYPE_BOOLEAN,
- .min = 0,
- .max = 1,
- .def = 0,
- .step = 1,
-};
-
-static const struct v4l2_ctrl_config vivid_ctrl_hdrenable = {
- .ops = &vivid_vid_cap_ctrl_ops,
- .id = VIVID_CID_HDR_EN,
- .name = "HDR enable",
- .type = V4L2_CTRL_TYPE_BOOLEAN,
- .min = 0,
- .max = 1,
- .def = 0,
- .step = 1,
-};
-
-static const struct v4l2_ctrl_config vivid_ctrl_sensor_modes = {
- .ops = &vivid_vid_cap_ctrl_ops,
- .id = VIVID_CID_SENSOR_MODES,
- .name = "Sensor Modes",
- .type = V4L2_CTRL_TYPE_INTEGER,
- .flags = V4L2_CTRL_FLAG_READ_ONLY,
- .min = 0,
- .max = MAX_NUM_SENSOR_MODES,
- .def = MAX_NUM_SENSOR_MODES,
- .step = 1,
-};
-
-static const struct v4l2_ctrl_config vivid_ctrl_signalprops = {
- .ops = &vivid_vid_cap_ctrl_ops,
- .id = VIVID_CID_SENSOR_SIGNAL_PROPERTIES,
- .name = "Sensor Signal Properties",
- .type = V4L2_CTRL_TYPE_U32,
- .flags = V4L2_CTRL_FLAG_HAS_PAYLOAD,
- .min = 0,
- .max = 0xFFFFFFFF,
- .step = 1,
- .def = 0,
- .dims = { MAX_NUM_SENSOR_MODES, SENSOR_SIGNAL_PROPERTIES_CID_SIZE },
-};
-
-static const struct v4l2_ctrl_config vivid_ctrl_imageprops = {
- .ops = &vivid_vid_cap_ctrl_ops,
- .id = VIVID_CID_SENSOR_IMAGE_PROPERTIES,
- .name = "Sensor Image Properties",
- .type = V4L2_CTRL_TYPE_U32,
- .flags = V4L2_CTRL_FLAG_HAS_PAYLOAD,
- .min = 0,
- .max = 0xFFFFFFFF,
- .step = 1,
- .def = 0,
- .dims = { MAX_NUM_SENSOR_MODES, SENSOR_IMAGE_PROPERTIES_CID_SIZE },
-};
-
-static const struct v4l2_ctrl_config vivid_ctrl_controlprops = {
- .ops = &vivid_vid_cap_ctrl_ops,
- .id = VIVID_CID_SENSOR_CONTROL_PROPERTIES,
- .name = "Sensor Control Properties",
- .type = V4L2_CTRL_TYPE_U32,
- .flags = V4L2_CTRL_FLAG_HAS_PAYLOAD,
- .min = 0,
- .max = 0xFFFFFFFF,
- .step = 1,
- .def = 0,
- .dims = { MAX_NUM_SENSOR_MODES, SENSOR_CONTROL_PROPERTIES_CID_SIZE },
-};
-
-static const struct v4l2_ctrl_config vivid_ctrl_dvtimings = {
- .ops = &vivid_vid_cap_ctrl_ops,
- .id = VIVID_CID_SENSOR_DV_TIMINGS,
- .name = "Sensor DV Timings",
- .type = V4L2_CTRL_TYPE_U32,
- .flags = V4L2_CTRL_FLAG_HAS_PAYLOAD,
- .min = 0,
- .max = 0xFFFFFFFF,
- .step = 1,
- .def = 0,
- .dims = { MAX_NUM_SENSOR_MODES, SENSOR_DV_TIMINGS_CID_SIZE },
-};
-
static const char * const vivid_ctrl_hor_movement_strings[] = {
"Move Left Fast",
"Move Left",
dev->autogain = v4l2_ctrl_new_std(hdl_user_vid, &vivid_user_vid_ctrl_ops,
V4L2_CID_AUTOGAIN, 0, 1, 1, 1);
dev->gain = v4l2_ctrl_new_std(hdl_user_vid, &vivid_user_vid_ctrl_ops,
- V4L2_CID_GAIN, 1, 256, 1, 100);
+ V4L2_CID_GAIN, 0, 255, 1, 100);
dev->alpha = v4l2_ctrl_new_std(hdl_user_vid, &vivid_user_vid_ctrl_ops,
V4L2_CID_ALPHA_COMPONENT, 0, 255, 1, 0);
}
v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_ycbcr_enc, NULL);
v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_quantization, NULL);
v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_alpha_mode, NULL);
- dev->framelength = v4l2_ctrl_new_custom(hdl_vid_cap,
- &vivid_ctrl_framelength, NULL);
- v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_coarsetime, NULL);
- v4l2_ctrl_new_custom(hdl_vid_cap,
- &vivid_ctrl_coarsetime_short, NULL);
- v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_grouphold, NULL);
- v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_hdrenable, NULL);
- dev->ctrl_signalprops = v4l2_ctrl_new_custom(hdl_vid_cap,
- &vivid_ctrl_signalprops, NULL);
- dev->ctrl_imageprops = v4l2_ctrl_new_custom(hdl_vid_cap,
- &vivid_ctrl_imageprops, NULL);
- dev->ctrl_controlprops = v4l2_ctrl_new_custom(hdl_vid_cap,
- &vivid_ctrl_controlprops, NULL);
- dev->ctrl_dvtimings = v4l2_ctrl_new_custom(hdl_vid_cap,
- &vivid_ctrl_dvtimings, NULL);
- dev->ctrl_sensormodes = v4l2_ctrl_new_custom(hdl_vid_cap,
- &vivid_ctrl_sensor_modes, NULL);
}
if (dev->has_vid_out && show_ccs_out) {
bool has_sdtv, bool has_hdmi);
void vivid_free_controls(struct vivid_dev *dev);
-int vivid_update_sensorprops(struct vivid_dev *dev);
-
#endif
}
}
-static void scale_line(const u8 *src, u8 *dst, unsigned srcw, unsigned dstw,
- unsigned twopixsize, unsigned packedpixels)
+static void scale_line(const u8 *src, u8 *dst, unsigned srcw, unsigned dstw, unsigned twopixsize)
{
/* Coarse scaling with Bresenham */
unsigned int_part;
/*
* We always combine two pixels to prevent color bleed in the packed
* yuv case.
- * only for packed 10bit case three pixels are packed to construct
- * 32 bit values. convert srcw and dstw to match the packing.
*/
- if (packedpixels == 3) {
- srcw /= 3;
- dstw /= 3;
- } else {
- srcw /= 2;
- dstw /= 2;
- }
+ srcw /= 2;
+ dstw /= 2;
int_part = srcw / dstw;
fract_part = srcw % dstw;
for (x = 0; x < dstw; x++, dst += twopixsize) {
voutbuf = plane_vaddr(tpg, vid_out_buf, p,
dev->bytesperline_out, dev->fmt_out_rect.height);
- /* copy embedded meta data */
- if (dev->fmt_cap->is_metadata[p] &&
- dev->fmt_out->is_metadata[p]) {
- unsigned size_out = vid_out_buf->vb.vb2_buf.planes[p].length;
- unsigned size_cap = vid_cap_buf->vb.vb2_buf.planes[p].length;
-
- size_out = size_out < size_cap ? size_out : size_cap;
- /* copy minimum of out and capture sessions */
- memcpy(vcapbuf, voutbuf, size_out);
- return 0;
- }
-
if (p < dev->fmt_out->buffers)
voutbuf += vid_out_buf->vb.vb2_buf.planes[p].data_offset;
voutbuf += tpg_hdiv(tpg, p, dev->loop_vid_out.left) +
scale_line(voutbuf + vid_out_y * stride_out, dev->scaled_line,
tpg_hdiv(tpg, p, dev->loop_vid_out.width),
tpg_hdiv(tpg, p, dev->loop_vid_cap.width),
- tpg_g_twopixelsize(tpg, p), tpg_g_packedpixels(tpg, p));
+ tpg_g_twopixelsize(tpg, p));
} else {
/*
* Offset in bytes within loop_vid_copy to the start of the
scale_line(voutbuf + vid_out_y * stride_out, dev->blended_line,
dev->loop_vid_out.width, dev->loop_vid_copy.width,
- tpg_g_twopixelsize(tpg, p), tpg_g_packedpixels(tpg, p));
+ tpg_g_twopixelsize(tpg, p));
if (blend)
blend_line(dev, vid_overlay_y + dev->loop_vid_overlay.top,
dev->loop_vid_overlay.left,
osd, (dev->loop_vid_overlay.width * twopixsize) / 2);
scale_line(dev->blended_line, dev->scaled_line,
dev->loop_vid_copy.width, dev->loop_vid_cap.width,
- tpg_g_twopixelsize(tpg, p), tpg_g_packedpixels(tpg, p));
+ tpg_g_twopixelsize(tpg, p));
}
dev->cur_scaled_line = vid_out_y;
memcpy(vcapbuf + vid_cap_left, dev->scaled_line,
for (p = 0; p < tpg_g_planes(tpg); p++) {
void *vbuf = plane_vaddr(tpg, buf, p,
- tpg->bytesperline, tpg->buf_height[p]);
+ tpg->bytesperline, tpg->buf_height);
/*
* The first plane of a multiplanar format has a non-zero
* data_offset. This helps testing whether the application
* correctly supports non-zero data offsets.
*/
- /*
- * Disable below code as it resets embedded data passed from
- * application.
if (p < tpg_g_buffers(tpg) && dev->fmt_cap->data_offset[p]) {
memset(vbuf, dev->fmt_cap->data_offset[p] & 0xff,
dev->fmt_cap->data_offset[p]);
vbuf += dev->fmt_cap->data_offset[p];
}
- */
-
tpg_calc_text_basep(tpg, basep, p, vbuf);
- if (!is_loop || vivid_copy_buffer(dev, p, vbuf, buf)) {
- if (!dev->fmt_cap->is_metadata[p])
- tpg_fill_plane_buffer(tpg, vivid_get_std_cap(dev),
+ if (!is_loop || vivid_copy_buffer(dev, p, vbuf, buf))
+ tpg_fill_plane_buffer(tpg, vivid_get_std_cap(dev),
p, vbuf);
- }
}
dev->must_blank[buf->vb.vb2_buf.index] = false;
- /* Write text to plane 0 instead of the last plane */
- tpg_calc_text_basep(tpg, basep, 0,
- plane_vaddr(tpg, buf, 0, tpg->bytesperline, tpg->buf_height[0]));
-
/* Updates stream time, only update at the start of a new frame. */
if (dev->field_cap != V4L2_FIELD_ALTERNATE ||
(buf->vb.sequence & 1) == 0)
break;
mutex_lock(&dev->mutex);
- mutex_lock(&dev->mutex_framerate);
cur_jiffies = jiffies;
if (dev->cap_seq_resync) {
dev->jiffies_vid_cap = cur_jiffies;
/* And the number of jiffies since we started */
jiffies_since_start = jiffies - dev->jiffies_vid_cap;
- mutex_unlock(&dev->mutex_framerate);
mutex_unlock(&dev->mutex);
/*
break;
mutex_lock(&dev->mutex);
- mutex_lock(&dev->mutex_framerate);
cur_jiffies = jiffies;
if (dev->out_seq_resync) {
dev->jiffies_vid_out = cur_jiffies;
dev->vbi_out_seq_count = dev->out_seq_count - dev->vbi_out_seq_start;
vivid_thread_vid_out_tick(dev);
- mutex_unlock(&dev->mutex_framerate);
mutex_unlock(&dev->mutex);
/*
{
memset(tpg, 0, sizeof(*tpg));
tpg->scaled_width = tpg->src_width = w;
- tpg->src_height = tpg->buf_height[0] = h;
+ tpg->src_height = tpg->buf_height = h;
tpg->crop.width = tpg->compose.width = w;
tpg->crop.height = tpg->compose.height = h;
tpg->recalc_colors = true;
tpg->mv_hor_mode = TPG_MOVE_NONE;
tpg->mv_vert_mode = TPG_MOVE_NONE;
tpg->field = V4L2_FIELD_NONE;
- tpg_s_fourcc(tpg, V4L2_PIX_FMT_RGB24, 0);
+ tpg_s_fourcc(tpg, V4L2_PIX_FMT_RGB24);
tpg->colorspace = V4L2_COLORSPACE_SRGB;
tpg->perc_fill = 100;
}
}
}
-bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc, u32 metadata_height)
+bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
{
tpg->fourcc = fourcc;
tpg->planes = 1;
tpg->interleaved = false;
tpg->vdownsampling[0] = 1;
tpg->hdownsampling[0] = 1;
- tpg->packedpixels[0] = 1;
- tpg->packedpixels[1] = 1;
- tpg->packedpixels[2] = 1;
tpg->hmask[0] = ~0;
tpg->hmask[1] = ~0;
tpg->hmask[2] = ~0;
switch (fourcc) {
- case V4L2_PIX_FMT_XBGGR10P:
- case V4L2_PIX_FMT_XGBRG10P:
- case V4L2_PIX_FMT_XGRBG10P:
- case V4L2_PIX_FMT_XRGGB10P:
- tpg->packedpixels[0] = 3;
- tpg->is_yuv = false;
- if (metadata_height) {
- tpg->buffers = 2;
- tpg->planes = 2;
- }
- tpg->vdownsampling[1] = 1;
- tpg->hdownsampling[1] = 1;
- break;
- case V4L2_PIX_FMT_SBGGR10:
- case V4L2_PIX_FMT_SGBRG10:
- case V4L2_PIX_FMT_SGRBG10:
- case V4L2_PIX_FMT_SRGGB10:
- if (metadata_height) {
- tpg->buffers = 2;
- tpg->planes = 2;
- }
- tpg->is_yuv = false;
- tpg->vdownsampling[1] = 1;
- tpg->hdownsampling[1] = 1;
- break;
case V4L2_PIX_FMT_SBGGR8:
case V4L2_PIX_FMT_SGBRG8:
case V4L2_PIX_FMT_SGRBG8:
case V4L2_PIX_FMT_SRGGB8:
+ case V4L2_PIX_FMT_SBGGR10:
+ case V4L2_PIX_FMT_SGBRG10:
+ case V4L2_PIX_FMT_SGRBG10:
+ case V4L2_PIX_FMT_SRGGB10:
case V4L2_PIX_FMT_SBGGR12:
case V4L2_PIX_FMT_SGBRG12:
case V4L2_PIX_FMT_SGRBG12:
tpg->twopixelsize[0] = 4;
tpg->twopixelsize[1] = 4;
break;
- case V4L2_PIX_FMT_XBGGR10P:
- case V4L2_PIX_FMT_XGBRG10P:
- case V4L2_PIX_FMT_XGRBG10P:
- case V4L2_PIX_FMT_XRGGB10P:
- tpg->twopixelsize[0] = 2 * 4;
- tpg->twopixelsize[1] = 2 * 4;
- break;
case V4L2_PIX_FMT_YUV422P:
case V4L2_PIX_FMT_YUV420:
case V4L2_PIX_FMT_YVU420:
tpg->src_width = width;
tpg->src_height = height;
tpg->field = field;
- tpg->buf_height[0] = height;
+ tpg->buf_height = height;
if (V4L2_FIELD_HAS_T_OR_B(field))
- tpg->buf_height[0] /= 2;
+ tpg->buf_height /= 2;
tpg->scaled_width = width;
tpg->crop.top = tpg->crop.left = 0;
tpg->crop.width = width;
tpg->crop.height = height;
tpg->compose.top = tpg->compose.left = 0;
tpg->compose.width = width;
- tpg->compose.height = tpg->buf_height[0];
- for (p = 0; p < tpg->planes; p++) {
+ tpg->compose.height = tpg->buf_height;
+ for (p = 0; p < tpg->planes; p++)
tpg->bytesperline[p] = (width * tpg->twopixelsize[p]) /
- (2 * tpg->hdownsampling[p] * tpg->packedpixels[p]);
- }
+ (2 * tpg->hdownsampling[p]);
tpg->recalc_square_border = true;
}
switch (field) {
case V4L2_FIELD_SEQ_TB:
if (y & 1)
- return tpg->buf_height[0] / 2 + y / 2;
+ return tpg->buf_height / 2 + y / 2;
return y / 2;
case V4L2_FIELD_SEQ_BT:
if (y & 1)
return y / 2;
- return tpg->buf_height[0] / 2 + y / 2;
+ return tpg->buf_height / 2 + y / 2;
default:
return y;
}
u8 *basep[TPG_MAX_PLANES][2], unsigned p, u8 *vbuf)
{
unsigned stride = tpg->bytesperline[p];
- unsigned h = tpg->buf_height[p];
+ unsigned h = tpg->buf_height;
tpg_recalc(tpg);
/* Source frame size */
unsigned src_width, src_height;
/* Buffer height */
- unsigned buf_height[TPG_MAX_PLANES];
+ unsigned buf_height;
/* Scaled output frame size */
unsigned scaled_width;
u32 field;
bool interleaved;
u8 vdownsampling[TPG_MAX_PLANES];
u8 hdownsampling[TPG_MAX_PLANES];
- u8 packedpixels[TPG_MAX_PLANES];
/*
* horizontal positions must be ANDed with this value to enforce
* correct boundaries for packed YUYV values.
unsigned p, u8 *vbuf);
void tpg_fillbuffer(struct tpg_data *tpg, v4l2_std_id std,
unsigned p, u8 *vbuf);
-bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc, u32 metadata_height);
+bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc);
void tpg_s_crop_compose(struct tpg_data *tpg, const struct v4l2_rect *crop,
const struct v4l2_rect *compose);
return tpg->twopixelsize[plane];
}
-static inline unsigned tpg_g_packedpixels(const struct tpg_data *tpg, unsigned plane)
-{
- return tpg->packedpixels[plane];
-}
-
static inline unsigned tpg_hdiv(const struct tpg_data *tpg,
unsigned plane, unsigned x)
{
- if (tpg->packedpixels[plane] > 1)
- return ((((x / tpg->hdownsampling[plane]) & tpg->hmask[plane]) *
- tpg->twopixelsize[plane]) /
- (2 * tpg->packedpixels[plane]));
- else
- return ((x / tpg->hdownsampling[plane]) & tpg->hmask[plane]) *
- (tpg->twopixelsize[plane] / 2);
+ return ((x / tpg->hdownsampling[plane]) & tpg->hmask[plane]) *
+ tpg->twopixelsize[plane] / 2;
}
static inline unsigned tpg_hscale(const struct tpg_data *tpg, unsigned x)
if (plane >= tpg_g_planes(tpg))
return 0;
- return tpg_g_bytesperline(tpg, plane) * tpg->buf_height[plane] /
+ return tpg_g_bytesperline(tpg, plane) * tpg->buf_height /
tpg->vdownsampling[plane];
}
-static inline unsigned tpg_g_buf_height(struct tpg_data *tpg, unsigned plane)
-{
- return tpg->buf_height[plane];
-}
-
-static inline void tpg_s_buf_height(struct tpg_data *tpg,
- unsigned p, unsigned h)
+static inline void tpg_s_buf_height(struct tpg_data *tpg, unsigned h)
{
- tpg->buf_height[p] = h;
+ tpg->buf_height = h;
}
static inline void tpg_s_field(struct tpg_data *tpg, unsigned field, bool alternate)
/* The number of discrete webcam frameintervals */
#define VIVID_WEBCAM_IVALS (VIVID_WEBCAM_SIZES * 2)
-#define VIVID_HDMI_SIZES 3
-
/* Sizes must be in increasing order */
static const struct v4l2_frmsize_discrete webcam_sizes[VIVID_WEBCAM_SIZES] = {
{ 320, 180 },
{ 1, 60 },
};
-static const struct v4l2_frmsize_discrete hdmi_sizes[VIVID_HDMI_SIZES] = {
- { 1280, 720 },
- { 1920, 1080 },
- { 3840, 2160 },
-};
-
static const struct v4l2_discrete_probe webcam_probe = {
webcam_sizes,
VIVID_WEBCAM_SIZES
if (fmt) {
const struct v4l2_pix_format_mplane *mp;
struct v4l2_format mp_fmt;
- struct vivid_fmt *vfmt;
+ const struct vivid_fmt *vfmt;
if (!V4L2_TYPE_IS_MULTIPLANAR(fmt->type)) {
fmt_sp2mp(fmt, &mp_fmt);
*/
if (mp->num_planes != buffers)
return -EINVAL;
-
vfmt = vivid_get_format(dev, mp->pixelformat);
for (p = 0; p < buffers; p++) {
sizes[p] = mp->plane_fmt[p].sizeimage;
- if (sizes[p] < tpg_g_line_width(&dev->tpg, p) *
- tpg_g_buf_height(&dev->tpg, p) +
+ if (sizes[p] < tpg_g_line_width(&dev->tpg, p) * h +
vfmt->data_offset[p])
return -EINVAL;
}
} else {
- for (p = 0; p < buffers; p++) {
- sizes[p] = tpg_g_line_width(&dev->tpg, p) *
- tpg_g_buf_height(&dev->tpg, p) +
+ for (p = 0; p < buffers; p++)
+ sizes[p] = tpg_g_line_width(&dev->tpg, p) * h +
dev->fmt_cap->data_offset[p];
- }
}
if (vq->num_buffers + *nbuffers < 2)
static int vid_cap_buf_prepare(struct vb2_buffer *vb)
{
struct vivid_dev *dev = vb2_get_drv_priv(vb->vb2_queue);
- struct vb2_queue *q = vb->vb2_queue;
unsigned long size;
unsigned buffers = tpg_g_buffers(&dev->tpg);
unsigned p;
- int err = 0;
dprintk(dev, 1, "%s\n", __func__);
return -EINVAL;
}
for (p = 0; p < buffers; p++) {
- size = tpg_g_line_width(&dev->tpg, p) *
- tpg_g_buf_height(&dev->tpg, p) +
+ size = tpg_g_line_width(&dev->tpg, p) * dev->fmt_cap_rect.height +
dev->fmt_cap->data_offset[p];
if (vb2_plane_size(vb, p) < size) {
vb2_set_plane_payload(vb, p, size);
vb->planes[p].data_offset = dev->fmt_cap->data_offset[p];
-
- if (q->memory == V4L2_MEMORY_DMABUF) {
- struct dma_buf *dbuf = dma_buf_get(vb->planes[p].m.fd);
- enum dma_data_direction dma_dir =
- q->is_output ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
-
- err = dma_buf_begin_cpu_access(dbuf, 0,
- vb->planes[p].length, dma_dir);
- if (err) {
- dprintk(dev, 1, "%s dma buf cpu access for plane %d failed\n",
- __func__, p);
- return err;
- }
- }
}
return 0;
struct v4l2_timecode *tc = &vbuf->timecode;
unsigned fps = 25;
unsigned seq = vbuf->sequence;
- unsigned p;
-
- /*
- * DMA mapping invalid during queue cancel and error
- * states. Only set up for the CPU copy when streaming.
- */
- if (vb->state == VB2_BUF_STATE_DONE) {
- for (p = 0; p < tpg_g_buffers(&dev->tpg); p++) {
- struct vb2_queue *q = vb->vb2_queue;
-
- if (q->memory == V4L2_MEMORY_DMABUF) {
- struct dma_buf *dbuf = dma_buf_get(vb->planes[p].m.fd);
- enum dma_data_direction dma_dir =
- q->is_output ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
-
- dma_buf_end_cpu_access(dbuf, 0,
- vb->planes[p].length, dma_dir);
- }
- }
- }
if (!vivid_is_sdtv_cap(dev))
return;
return TPG_PIXEL_ASPECT_SQUARE;
}
-void vivid_update_timeperframe(struct vivid_dev *dev, u32 frame_length)
-{
- struct v4l2_bt_timings *bt = &dev->dv_timings_cap.bt;
- unsigned size;
-
- mutex_lock(&dev->mutex_framerate);
-
- dev->cap_seq_resync = true;
- size = V4L2_DV_BT_FRAME_WIDTH(bt) * frame_length;
- dev->timeperframe_vid_cap = (struct v4l2_fract) {
- size / 100, (u32)bt->pixelclock / 100
- };
-
- if (dev->loop_video) {
- dev->out_seq_resync = true;
- dev->timeperframe_vid_out = (struct v4l2_fract) {
- size / 100, (u32)bt->pixelclock / 100
- };
- }
-
- mutex_unlock(&dev->mutex_framerate);
-}
-
/*
* Called whenever the format has to be reset which can occur when
* changing inputs, standard, timings, etc.
mp->xfer_func = vivid_xfer_func_cap(dev);
mp->ycbcr_enc = vivid_ycbcr_enc_cap(dev);
mp->quantization = vivid_quantization_cap(dev);
- mp->num_planes = tpg_g_planes(&dev->tpg);
- mp->metadata_height = dev->embedded_data_height;
+ mp->num_planes = dev->fmt_cap->buffers;
for (p = 0; p < mp->num_planes; p++) {
- mp->plane_fmt[p].bytesperline =
- tpg_g_bytesperline(&dev->tpg, p);
+ mp->plane_fmt[p].bytesperline = tpg_g_bytesperline(&dev->tpg, p);
mp->plane_fmt[p].sizeimage =
- mp->plane_fmt[p].bytesperline *
- tpg_g_buf_height(&dev->tpg, p) +
+ tpg_g_line_width(&dev->tpg, p) * mp->height +
dev->fmt_cap->data_offset[p];
}
return 0;
unsigned factor = 1;
unsigned w, h;
unsigned p;
- unsigned packedpixels;
fmt = vivid_get_format(dev, mp->pixelformat);
if (!fmt) {
mp->pixelformat = V4L2_PIX_FMT_YUYV;
fmt = vivid_get_format(dev, mp->pixelformat);
}
- packedpixels = fmt->packedpixels;
- if (!packedpixels)
- packedpixels = 1;
mp->field = vivid_field_cap(dev, mp->field);
if (vivid_is_webcam(dev)) {
mp->height = r.height / factor;
}
- /* clip metadata height maximum value */
- if (mp->metadata_height > MAX_METADATA_HEIGHT)
- mp->metadata_height = MAX_METADATA_HEIGHT;
-
/* This driver supports custom bytesperline values */
mp->num_planes = fmt->buffers;
for (p = 0; p < mp->num_planes; p++) {
/* Calculate the minimum supported bytesperline value */
- bytesperline = ((mp->width * fmt->bit_depth[p]) >> 3) /
- packedpixels;
+ bytesperline = (mp->width * fmt->bit_depth[p]) >> 3;
/* Calculate the maximum supported bytesperline value */
max_bpl = (MAX_ZOOM * MAX_WIDTH * fmt->bit_depth[p]) >> 3;
pfmt[p].bytesperline = max_bpl;
if (pfmt[p].bytesperline < bytesperline)
pfmt[p].bytesperline = bytesperline;
- pfmt[p].sizeimage =
- tpg_calc_line_width(&dev->tpg, p, pfmt[p].bytesperline) *
- (fmt->is_metadata[p] ? mp->metadata_height : mp->height) +
- fmt->data_offset[p];
+ pfmt[p].sizeimage = tpg_calc_line_width(&dev->tpg, p, pfmt[p].bytesperline) *
+ mp->height + fmt->data_offset[p];
memset(pfmt[p].reserved, 0, sizeof(pfmt[p].reserved));
}
mp->colorspace = vivid_colorspace_cap(dev);
unsigned factor = 1;
unsigned p;
unsigned i;
- unsigned planes;
if (ret < 0)
return ret;
dev->fmt_cap_rect.width = mp->width;
dev->fmt_cap_rect.height = mp->height;
- tpg_s_fourcc(&dev->tpg, dev->fmt_cap->fourcc, mp->metadata_height);
- for (p = 0; p < tpg_g_buffers(&dev->tpg); p++) {
- unsigned height = dev->fmt_cap->is_metadata[p] ?
- mp->metadata_height : mp->height;
- tpg_s_buf_height(&dev->tpg, p, height);
- }
- dev->embedded_data_height = mp->metadata_height;
+ tpg_s_buf_height(&dev->tpg, mp->height);
+ tpg_s_fourcc(&dev->tpg, dev->fmt_cap->fourcc);
for (p = 0; p < tpg_g_buffers(&dev->tpg); p++)
tpg_s_bytesperline(&dev->tpg, p, mp->plane_fmt[p].bytesperline);
dev->field_cap = mp->field;
if (vivid_is_sdtv_cap(dev))
dev->tv_field_cap = mp->field;
tpg_update_mv_step(&dev->tpg);
- // update framelength control to control framerate
- v4l2_ctrl_s_ctrl(dev->framelength,
- V4L2_DV_BT_FRAME_HEIGHT(&dev->dv_timings_cap.bt));
return 0;
}
rect_set_max_size(compose, &max_rect);
}
dev->fmt_cap_rect = fmt;
- tpg_s_buf_height(&dev->tpg, 0, fmt.height);
+ tpg_s_buf_height(&dev->tpg, fmt.height);
} else if (dev->has_compose_cap) {
struct v4l2_rect fmt = dev->fmt_cap_rect;
vb2_is_busy(&dev->vb_vid_cap_q))
return -EBUSY;
dev->fmt_cap_rect = fmt;
- tpg_s_buf_height(&dev->tpg, 0, fmt.height);
+ tpg_s_buf_height(&dev->tpg, fmt.height);
rect_set_size_to(compose, &s->r);
rect_map_inside(compose, &dev->fmt_cap_rect);
} else {
rect_set_size_to(&dev->fmt_cap_rect, &s->r);
rect_set_size_to(compose, &s->r);
rect_map_inside(compose, &dev->fmt_cap_rect);
- tpg_s_buf_height(&dev->tpg, 0, dev->fmt_cap_rect.height);
+ tpg_s_buf_height(&dev->tpg, dev->fmt_cap_rect.height);
}
s->r.top *= factor;
s->r.height *= factor;
dev->dv_timings_cap = *timings;
vivid_update_format_cap(dev, false);
- // update framelength control to control framerate
- v4l2_ctrl_s_ctrl(dev->framelength,
- V4L2_DV_BT_FRAME_HEIGHT(&dev->dv_timings_cap.bt));
return 0;
}
fsize->discrete = webcam_sizes[fsize->index];
return 0;
}
- if (vivid_is_hdmi_cap(dev)) {
- if (fsize->index >= ARRAY_SIZE(hdmi_sizes))
- return -EINVAL;
- fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
- fsize->discrete = hdmi_sizes[fsize->index];
- return 0;
- }
if (fsize->index)
return -EINVAL;
fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
int vidioc_enum_frameintervals(struct file *file, void *priv, struct v4l2_frmivalenum *fival);
int vivid_vid_cap_g_parm(struct file *file, void *priv, struct v4l2_streamparm *parm);
int vivid_vid_cap_s_parm(struct file *file, void *priv, struct v4l2_streamparm *parm);
-void vivid_update_timeperframe(struct vivid_dev *dev, u32 frame_length);
#endif
},
{
.fourcc = V4L2_PIX_FMT_SBGGR10, /* Bayer BG/GR */
- .is_metadata = { 0, 1},
- .vdownsampling = { 1, 1 },
- .bit_depth = { 16, 16 },
- .planes = 2,
- .buffers = 2,
- },
- {
- .fourcc = V4L2_PIX_FMT_SGBRG10, /* Bayer GB/RG */
- .is_metadata = { 0, 1},
- .vdownsampling = { 1, 1 },
- .bit_depth = { 16, 16 },
- .planes = 2,
- .buffers = 2,
- },
- {
- .fourcc = V4L2_PIX_FMT_SGRBG10, /* Bayer GR/BG */
- .is_metadata = { 0, 1},
- .vdownsampling = { 1, 1 },
- .bit_depth = { 16, 16 },
- .planes = 2,
- .buffers = 2,
- },
- {
- .fourcc = V4L2_PIX_FMT_SRGGB10, /* Bayer RG/GB */
- .is_metadata = { 0, 1},
- .vdownsampling = { 1, 1 },
- .bit_depth = { 16, 16 },
- .planes = 2,
- .buffers = 2,
- },
- {
- .fourcc = V4L2_PIX_FMT_SBGGR12, /* Bayer BG/GR */
.vdownsampling = { 1 },
.bit_depth = { 16 },
.planes = 1,
.buffers = 1,
},
{
- .fourcc = V4L2_PIX_FMT_SGBRG12, /* Bayer GB/RG */
+ .fourcc = V4L2_PIX_FMT_SGBRG10, /* Bayer GB/RG */
.vdownsampling = { 1 },
.bit_depth = { 16 },
.planes = 1,
.buffers = 1,
},
{
- .fourcc = V4L2_PIX_FMT_SGRBG12, /* Bayer GR/BG */
+ .fourcc = V4L2_PIX_FMT_SGRBG10, /* Bayer GR/BG */
.vdownsampling = { 1 },
.bit_depth = { 16 },
.planes = 1,
.buffers = 1,
},
{
- .fourcc = V4L2_PIX_FMT_SRGGB12, /* Bayer RG/GB */
+ .fourcc = V4L2_PIX_FMT_SRGGB10, /* Bayer RG/GB */
.vdownsampling = { 1 },
.bit_depth = { 16 },
.planes = 1,
.buffers = 1,
},
{
- .fourcc = V4L2_PIX_FMT_SBGGR16, /* Bayer BG/GR */
+ .fourcc = V4L2_PIX_FMT_SBGGR12, /* Bayer BG/GR */
.vdownsampling = { 1 },
.bit_depth = { 16 },
.planes = 1,
.buffers = 1,
},
{
- .fourcc = V4L2_PIX_FMT_SGBRG16, /* Bayer GB/RG */
+ .fourcc = V4L2_PIX_FMT_SGBRG12, /* Bayer GB/RG */
.vdownsampling = { 1 },
.bit_depth = { 16 },
.planes = 1,
.buffers = 1,
},
{
- .fourcc = V4L2_PIX_FMT_SGRBG16, /* Bayer GR/BG */
+ .fourcc = V4L2_PIX_FMT_SGRBG12, /* Bayer GR/BG */
.vdownsampling = { 1 },
.bit_depth = { 16 },
.planes = 1,
.buffers = 1,
},
{
- .fourcc = V4L2_PIX_FMT_SRGGB16, /* Bayer RG/GB */
+ .fourcc = V4L2_PIX_FMT_SRGGB12, /* Bayer RG/GB */
.vdownsampling = { 1 },
.bit_depth = { 16 },
.planes = 1,
.buffers = 1,
},
- {
- .fourcc = V4L2_PIX_FMT_XBGGR10P, /* Packed Bayer BG/GR */
- .is_metadata = { 0, 1},
- .vdownsampling = { 1, 1 },
- .packedpixels = 3,
- .bit_depth = { 32, 32},
- .planes = 2,
- .buffers = 2,
- },
- {
- .fourcc = V4L2_PIX_FMT_XGBRG10P, /* Packed Bayer GB/RG */
- .is_metadata = { 0, 1},
- .vdownsampling = { 1, 1 },
- .packedpixels = 3,
- .bit_depth = { 32, 32 },
- .planes = 2,
- .buffers = 2,
- },
- {
- .fourcc = V4L2_PIX_FMT_XGRBG10P, /* Packed Bayer GR/BG */
- .is_metadata = { 0, 1},
- .vdownsampling = { 1, 1 },
- .packedpixels = 3,
- .bit_depth = { 32, 32 },
- .planes = 2,
- .buffers = 2,
- },
- {
- .fourcc = V4L2_PIX_FMT_XRGGB10P, /* Packed Bayer RG/GB */
- .is_metadata = { 0, 1},
- .vdownsampling = { 1, 1 },
- .packedpixels = 3,
- .bit_depth = { 32, 32 },
- .planes = 2,
- .buffers = 2,
- },
{
.fourcc = V4L2_PIX_FMT_NV16M,
.vdownsampling = { 1, 1 },
const struct v4l2_format *fmt = parg;
struct vivid_dev *dev = vb2_get_drv_priv(vq);
const struct vivid_fmt *vfmt = dev->fmt_out;
- unsigned planes = dev->fmt_out_metadata_height ? vfmt->buffers : (vfmt->buffers - 1);
+ unsigned planes = vfmt->buffers;
unsigned h = dev->fmt_out_rect.height;
- unsigned size = dev->bytesperline_out[0] * (h + dev->fmt_out_metadata_height);
+ unsigned size = dev->bytesperline_out[0] * h;
unsigned p;
- for (p = vfmt->buffers; p < planes; p++)
+ for (p = vfmt->buffers; p < vfmt->planes; p++)
size += dev->bytesperline_out[p] * h / vfmt->vdownsampling[p];
if (dev->field_out == V4L2_FIELD_ALTERNATE) {
* Check if the number of planes in the specified format match
* the number of planes in the current format. You can't mix that.
*/
- if (mp->num_planes != planes)
+ if (mp->num_planes != planes)
return -EINVAL;
sizes[0] = mp->plane_fmt[0].sizeimage;
if (sizes[0] < size)
return -EINVAL;
planes = dev->fmt_out->planes;
- planes -= dev->fmt_out_metadata_height ? 0 : 1;
if (dev->buf_prepare_error) {
/*
{
struct v4l2_bt_timings *bt = &dev->dv_timings_out.bt;
unsigned size, p;
- unsigned packedpixels = dev->fmt_out->packedpixels;
switch (dev->output_type[dev->output]) {
case SVID:
if (V4L2_FIELD_HAS_T_OR_B(dev->field_out))
dev->crop_out.height /= 2;
dev->fmt_out_rect = dev->crop_out;
- if (!packedpixels)
- packedpixels = 1;
for (p = 0; p < dev->fmt_out->planes; p++)
dev->bytesperline_out[p] =
- (dev->sink_rect.width * dev->fmt_out->bit_depth[p]) /
- (8 * packedpixels);
+ (dev->sink_rect.width * dev->fmt_out->bit_depth[p]) / 8;
}
/* Map the field to something that is valid for the current output */
const struct vivid_fmt *fmt = dev->fmt_out;
unsigned p;
- mp->width = dev->fmt_out_rect.width;
+ mp->width = dev->fmt_out_rect.width;
mp->height = dev->fmt_out_rect.height;
- mp->field = dev->field_out;
+ mp->field = dev->field_out;
mp->pixelformat = fmt->fourcc;
mp->colorspace = dev->colorspace_out;
mp->xfer_func = dev->xfer_func_out;
mp->ycbcr_enc = dev->ycbcr_enc_out;
mp->quantization = dev->quantization_out;
- mp->num_planes = dev->fmt_out_metadata_height ? fmt->buffers : (fmt->buffers - 1);
- mp->metadata_height = dev->fmt_out_metadata_height;
+ mp->num_planes = fmt->buffers;
for (p = 0; p < mp->num_planes; p++) {
mp->plane_fmt[p].bytesperline = dev->bytesperline_out[p];
mp->plane_fmt[p].sizeimage =
- mp->plane_fmt[p].bytesperline * dev->height_out[p];
+ mp->plane_fmt[p].bytesperline * mp->height;
}
for (p = fmt->buffers; p < fmt->planes; p++) {
unsigned stride = dev->bytesperline_out[p];
unsigned factor = 1;
unsigned w, h;
unsigned p;
- unsigned packedpixels;
fmt = vivid_get_format(dev, mp->pixelformat);
if (!fmt) {
mp->pixelformat = V4L2_PIX_FMT_YUYV;
fmt = vivid_get_format(dev, mp->pixelformat);
}
- packedpixels = fmt->packedpixels;
- if (!packedpixels)
- packedpixels = 1;
mp->field = vivid_field_out(dev, mp->field);
if (vivid_is_svid_out(dev)) {
mp->height = r.height / factor;
}
- /* clip metadata height maximum value */
- if (mp->metadata_height > MAX_METADATA_HEIGHT)
- mp->metadata_height = MAX_METADATA_HEIGHT;
-
/* This driver supports custom bytesperline values */
/* Calculate the minimum supported bytesperline value */
- bytesperline = ((mp->width * fmt->bit_depth[0]) >> 3) / packedpixels;
+ bytesperline = (mp->width * fmt->bit_depth[0]) >> 3;
/* Calculate the maximum supported bytesperline value */
max_bpl = (MAX_ZOOM * MAX_WIDTH * fmt->bit_depth[0]) >> 3;
- mp->num_planes = dev->fmt_out_metadata_height ? fmt->buffers : (fmt->buffers - 1);
+ mp->num_planes = fmt->buffers;
for (p = 0; p < mp->num_planes; p++) {
if (pfmt[p].bytesperline > max_bpl)
pfmt[p].bytesperline = max_bpl;
if (pfmt[p].bytesperline < bytesperline)
pfmt[p].bytesperline = bytesperline;
- pfmt[p].sizeimage = pfmt[p].bytesperline *
- (fmt->is_metadata[p] ? mp->metadata_height : mp->height);
+ pfmt[p].sizeimage = pfmt[p].bytesperline * mp->height;
memset(pfmt[p].reserved, 0, sizeof(pfmt[p].reserved));
}
for (p = fmt->buffers; p < fmt->planes; p++)
dev->fmt_out_rect.width = mp->width;
dev->fmt_out_rect.height = mp->height;
- for (p = 0; p < mp->num_planes; p++) {
+ for (p = 0; p < mp->num_planes; p++)
dev->bytesperline_out[p] = mp->plane_fmt[p].bytesperline;
- dev->height_out[p] = dev->fmt_out->is_metadata[p] ?
- mp->metadata_height : mp->height;
- }
- dev->fmt_out_metadata_height = mp->metadata_height;
for (p = dev->fmt_out->buffers; p < dev->fmt_out->planes; p++)
dev->bytesperline_out[p] =
(dev->bytesperline_out[0] * dev->fmt_out->bit_depth[p]) /