static void frame_init_yuv_planes(struct ia_css_frame *frame, unsigned int horizontal_decimation, unsigned int vertical_decimation, bool swap_uv, unsigned int bytes_per_element) { unsigned int y_width = frame->info.padded_width, y_height = frame->info.res.height, uv_width = y_width / horizontal_decimation, uv_height = y_height / vertical_decimation, y_stride, y_bytes, uv_bytes, uv_stride; y_stride = y_width * bytes_per_element; uv_stride = uv_width * bytes_per_element; y_bytes = y_stride * y_height; uv_bytes = uv_stride * uv_height; frame->data_bytes = y_bytes + 2 * uv_bytes; frame_init_plane(&frame->planes.yuv.y, y_width, y_stride, y_height, 0); if (swap_uv) { frame_init_plane(&frame->planes.yuv.v, uv_width, uv_stride, uv_height, y_bytes); frame_init_plane(&frame->planes.yuv.u, uv_width, uv_stride, uv_height, y_bytes + uv_bytes); } else { frame_init_plane(&frame->planes.yuv.u, uv_width, uv_stride, uv_height, y_bytes); frame_init_plane(&frame->planes.yuv.v, uv_width, uv_stride, uv_height, y_bytes + uv_bytes); } return; }
static void frame_init_nv_planes(struct ia_css_frame *frame, unsigned int horizontal_decimation, unsigned int vertical_decimation) { unsigned int y_width = frame->info.padded_width, y_height = frame->info.res.height, uv_width = 2 * (y_width / horizontal_decimation), uv_height = y_height / vertical_decimation, y_bytes, uv_bytes; if (IA_CSS_FRAME_FORMAT_NV12_TILEY == frame->info.format) { y_width = CEIL_MUL(y_width, NV12_TILEY_TILE_WIDTH); uv_width = CEIL_MUL(uv_width, NV12_TILEY_TILE_WIDTH); y_height = CEIL_MUL(y_height, NV12_TILEY_TILE_HEIGHT); uv_height = CEIL_MUL(uv_height, NV12_TILEY_TILE_HEIGHT); } y_bytes = y_width * y_height; uv_bytes = uv_width * uv_height; frame->data_bytes = y_bytes + uv_bytes; frame_init_plane(&frame->planes.nv.y, y_width, y_width, y_height, 0); frame_init_plane(&frame->planes.nv.uv, uv_width, uv_width, uv_height, y_bytes); return; }
static void frame_init_rgb_planes(struct ia_css_frame *frame, unsigned int bytes_per_element) { unsigned int width = frame->info.res.width, height = frame->info.res.height, stride, bytes; stride = width * bytes_per_element; bytes = stride * height; frame->data_bytes = 3 * bytes; frame_init_plane(&frame->planes.planar_rgb.r, width, stride, height, 0); frame_init_plane(&frame->planes.planar_rgb.g, width, stride, height, 1 * bytes); frame_init_plane(&frame->planes.planar_rgb.b, width, stride, height, 2 * bytes); return; }
static void frame_init_nv_planes(struct ia_css_frame *frame, unsigned int horizontal_decimation, unsigned int vertical_decimation) { unsigned int y_width = frame->info.padded_width, y_height = frame->info.res.height, uv_width = 2 * (y_width / horizontal_decimation), uv_height = y_height / vertical_decimation, y_bytes, uv_bytes; y_bytes = y_width * y_height; uv_bytes = uv_width * uv_height; frame->data_bytes = y_bytes + uv_bytes; frame_init_plane(&frame->planes.nv.y, y_width, y_width, y_height, 0); frame_init_plane(&frame->planes.nv.uv, uv_width, uv_width, uv_height, y_bytes); return; }
static void frame_init_mipi_plane(struct ia_css_frame *frame, struct ia_css_frame_plane *plane, unsigned int height, unsigned int subpixels_per_line, unsigned int bytes_per_pixel) { unsigned int stride; stride = subpixels_per_line * bytes_per_pixel; frame->data_bytes = 8388608; frame->valid = false; frame->contiguous = true; frame_init_plane(plane, subpixels_per_line, stride, height, 0); return; }
static void frame_init_raw_single_plane( struct ia_css_frame *frame, struct ia_css_frame_plane *plane, unsigned int height, unsigned int subpixels_per_line, unsigned int bits_per_pixel) { unsigned int stride; assert(frame != NULL); stride = HIVE_ISP_DDR_WORD_BYTES * CEIL_DIV(subpixels_per_line, HIVE_ISP_DDR_WORD_BITS / bits_per_pixel); frame->data_bytes = stride * height; frame_init_plane(plane, subpixels_per_line, stride, height, 0); return; }
static void frame_init_single_plane(struct ia_css_frame *frame, struct ia_css_frame_plane *plane, unsigned int height, unsigned int subpixels_per_line, unsigned int bytes_per_pixel) { unsigned int stride; stride = subpixels_per_line * bytes_per_pixel; /* Frame height needs to be even number - needed by hw ISYS2401 In case of odd number, round up to even. Images won't be impacted by this round up, only needed by jpeg/embedded data. As long as buffer allocation and release are using data_bytes, there won't be memory leak. */ frame->data_bytes = stride * CEIL_MUL2(height, 2); frame_init_plane(plane, subpixels_per_line, stride, height, 0); return; }
static void frame_init_qplane6_planes(struct ia_css_frame *frame) { unsigned int width = frame->info.padded_width / 2, height = frame->info.res.height / 2, bytes, stride; stride = width * 2; bytes = stride * height; frame->data_bytes = 6 * bytes; frame_init_plane(&frame->planes.plane6.r, width, stride, height, 0 * bytes); frame_init_plane(&frame->planes.plane6.r_at_b, width, stride, height, 1 * bytes); frame_init_plane(&frame->planes.plane6.gr, width, stride, height, 2 * bytes); frame_init_plane(&frame->planes.plane6.gb, width, stride, height, 3 * bytes); frame_init_plane(&frame->planes.plane6.b, width, stride, height, 4 * bytes); frame_init_plane(&frame->planes.plane6.b_at_r, width, stride, height, 5 * bytes); return; }