/* * The IC Resizer has a restriction that the output frame from the * resizer must be 1024 or less in both width (pixels) and height * (lines). * * The image converter attempts to split up a conversion when * the desired output (converted) frame resolution exceeds the * IC resizer limit of 1024 in either dimension. * * If either dimension of the output frame exceeds the limit, the * dimension is split into 1, 2, or 4 equal stripes, for a maximum * of 4*4 or 16 tiles. A conversion is then carried out for each * tile (but taking care to pass the full frame stride length to * the DMA channel's parameter memory!). IDMA double-buffering is used * to convert each tile back-to-back when possible (see note below * when double_buffering boolean is set). * * Note that the input frame must be split up into the same number * of tiles as the output frame: * * +---------+-----+ * +-----+---+ | A | B | * | A | B | | | | * +-----+---+ --> +---------+-----+ * | C | D | | C | D | * +-----+---+ | | | * +---------+-----+ * * Clockwise 90° rotations are handled by first rescaling into a * reusable temporary tile buffer and then rotating with the 8x8 * block rotator, writing to the correct destination: * * +-----+-----+ * | | | * +-----+---+ +---------+ | C | A | * | A | B | | A,B, | | | | | * +-----+---+ --> | C,D | | --> | | | * | C | D | +---------+ +-----+-----+ * +-----+---+ | D | B | * | | | * +-----+-----+ * * If the 8x8 block rotator is used, horizontal or vertical flipping * is done during the rotation step, otherwise flipping is done * during the scaling step. * With rotation or flipping, tile order changes between input and * output image. Tiles are numbered row major from top left to bottom * right for both input and output image.
*/
struct ipu_image_convert_dma_chan { int in; int out; int rot_in; int rot_out; int vdi_in_p; int vdi_in; int vdi_in_n;
};
/* dimensions of one tile */ struct ipu_image_tile {
u32 width;
u32 height;
u32 left;
u32 top; /* size and strides are in bytes */
u32 size;
u32 stride;
u32 rot_stride; /* start Y or packed offset of this tile */
u32 offset; /* offset from start to tile in U plane, for planar formats */
u32 u_off; /* offset from start to tile in V plane, for planar formats */
u32 v_off;
};
/* # of rows (horizontal stripes) if dest height is > 1024 */ unsignedint num_rows; /* # of columns (vertical stripes) if dest width is > 1024 */ unsignedint num_cols;
struct ipu_image_tile tile[MAX_TILES];
};
struct ipu_image_pixfmt {
u32 fourcc; /* V4L2 fourcc */ int bpp; /* total bpp */ int uv_width_dec; /* decimation in width for U/V planes */ int uv_height_dec; /* decimation in height for U/V planes */ bool planar; /* planar format */ bool uv_swapped; /* U and V planes are swapped */ bool uv_packed; /* partial planar (U and V in same plane) */
};
/* intermediate buffer for rotation */ struct ipu_image_convert_dma_buf rot_intermediate[2];
/* current buffer number for double buffering */ int cur_buf_num;
bool aborting; struct completion aborted;
/* can we use double-buffering for this conversion operation? */ bool double_buffering; /* num_rows * num_cols */ unsignedint num_tiles; /* next tile to process */ unsignedint next_tile; /* where to place converted tile in dest image */ unsignedint out_tile_map[MAX_TILES];
/* mask of completed EOF irqs at every tile conversion */ enum eof_irq_mask eof_mask;
/* * Calculate downsizing coefficients, which are the same for all tiles, * and initial bilinear resizing coefficients, which are used to find the * best seam positions. * Also determine the number of tiles necessary to guarantee that no tile * is larger than 1024 pixels in either dimension at the output and between * IC downsizing and main processing sections.
*/ staticint calc_image_resize_coefficients(struct ipu_image_convert_ctx *ctx, struct ipu_image *in, struct ipu_image *out)
{
u32 downsized_width = in->rect.width;
u32 downsized_height = in->rect.height;
u32 downsize_coeff_v = 0;
u32 downsize_coeff_h = 0;
u32 resized_width = out->rect.width;
u32 resized_height = out->rect.height;
u32 resize_coeff_h;
u32 resize_coeff_v;
u32 cols;
u32 rows;
if (ipu_rot_mode_is_irt(ctx->rot_mode)) {
resized_width = out->rect.height;
resized_height = out->rect.width;
}
/* Do not let invalid input lead to an endless loop below */ if (WARN_ON(resized_width == 0 || resized_height == 0)) return -EINVAL;
/* * Calculate the bilinear resizing coefficients that could be used if * we were converting with a single tile. The bottom right output pixel * should sample as close as possible to the bottom right input pixel * out of the decimator, but not overshoot it:
*/
resize_coeff_h = 8192 * (downsized_width - 1) / (resized_width - 1);
resize_coeff_v = 8192 * (downsized_height - 1) / (resized_height - 1);
/* * Both the output of the IC downsizing section before being passed to * the IC main processing section and the final output of the IC main * processing section must be <= 1024 pixels in both dimensions.
*/
cols = num_stripes(max_t(u32, downsized_width, resized_width));
rows = num_stripes(max_t(u32, downsized_height, resized_height));
/* * Find the best aligned seam position for the given column / row index. * Rotation and image offsets are out of scope. * * @index: column / row index, used to calculate valid interval * @in_edge: input right / bottom edge * @out_edge: output right / bottom edge * @in_align: input alignment, either horizontal 8-byte line start address * alignment, or pixel alignment due to image format * @out_align: output alignment, either horizontal 8-byte line start address * alignment, or pixel alignment due to image format or rotator * block size * @in_burst: horizontal input burst size in case of horizontal flip * @out_burst: horizontal output burst size or rotator block size * @downsize_coeff: downsizing section coefficient * @resize_coeff: main processing section resizing coefficient * @_in_seam: aligned input seam position return value * @_out_seam: aligned output seam position return value
*/ staticvoid find_best_seam(struct ipu_image_convert_ctx *ctx, unsignedint index, unsignedint in_edge, unsignedint out_edge, unsignedint in_align, unsignedint out_align, unsignedint in_burst, unsignedint out_burst, unsignedint downsize_coeff, unsignedint resize_coeff,
u32 *_in_seam,
u32 *_out_seam)
{ struct device *dev = ctx->chan->priv->ipu->dev; unsignedint out_pos; /* Input / output seam position candidates */ unsignedint out_seam = 0; unsignedint in_seam = 0; unsignedint min_diff = UINT_MAX; unsignedint out_start; unsignedint out_end; unsignedint in_start; unsignedint in_end;
/* Start within 1024 pixels of the right / bottom edge */
out_start = max_t(int, index * out_align, out_edge - 1024); /* End before having to add more columns to the left / rows above */
out_end = min_t(unsignedint, out_edge, index * 1024 + 1);
/* * Limit input seam position to make sure that the downsized input tile * to the right or bottom does not exceed 1024 pixels.
*/
in_start = max_t(int, index * in_align,
in_edge - (1024 << downsize_coeff));
in_end = min_t(unsignedint, in_edge,
index * (1024 << downsize_coeff) + 1);
/* * Output tiles must start at a multiple of 8 bytes horizontally and * possibly at an even line horizontally depending on the pixel format. * Only consider output aligned positions for the seam.
*/
out_start = round_up(out_start, out_align); for (out_pos = out_start; out_pos < out_end; out_pos += out_align) { unsignedint in_pos; unsignedint in_pos_aligned; unsignedint in_pos_rounded; unsignedint diff;
/* * Tiles in the right row / bottom column may not be allowed to * overshoot horizontally / vertically. out_burst may be the * actual DMA burst size, or the rotator block size.
*/ if ((out_burst > 1) && (out_edge - out_pos) % out_burst) continue;
/* * Input sample position, corresponding to out_pos, 19.13 fixed * point.
*/
in_pos = (out_pos * resize_coeff) << downsize_coeff; /* * The closest input sample position that we could actually * start the input tile at, 19.13 fixed point.
*/
in_pos_aligned = round_closest(in_pos, 8192U * in_align); /* Convert 19.13 fixed point to integer */
in_pos_rounded = in_pos_aligned / 8192U;
if (in_pos_rounded < in_start) continue; if (in_pos_rounded >= in_end) break;
/* * Tile left edges are required to be aligned to multiples of 8 bytes * by the IDMAC.
*/ staticinline u32 tile_left_align(conststruct ipu_image_pixfmt *fmt)
{ if (fmt->planar) return fmt->uv_packed ? 8 : 8 * fmt->uv_width_dec; else return fmt->bpp == 32 ? 2 : fmt->bpp == 16 ? 4 : 8;
}
/* * Tile top edge alignment is only limited by chroma subsampling.
*/ staticinline u32 tile_top_align(conststruct ipu_image_pixfmt *fmt)
{ return fmt->uv_height_dec > 1 ? 2 : 1;
}
staticinline u32 tile_width_align(enum ipu_image_convert_type type, conststruct ipu_image_pixfmt *fmt, enum ipu_rotate_mode rot_mode)
{ if (type == IMAGE_CONVERT_IN) { /* * The IC burst reads 8 pixels at a time. Reading beyond the * end of the line is usually acceptable. Those pixels are * ignored, unless the IC has to write the scaled line in * reverse.
*/ return (!ipu_rot_mode_is_irt(rot_mode) &&
(rot_mode & IPU_ROT_BIT_HFLIP)) ? 8 : 2;
}
/* * Align to 16x16 pixel blocks for planar 4:2:0 chroma subsampled * formats to guarantee 8-byte aligned line start addresses in the * chroma planes when IRT is used. Align to 8x8 pixel IRT block size * for all other formats.
*/ return (ipu_rot_mode_is_irt(rot_mode) &&
fmt->planar && !fmt->uv_packed) ?
8 * fmt->uv_width_dec : 8;
}
/* * Align to 16x16 pixel blocks for planar 4:2:0 chroma subsampled * formats to guarantee 8-byte aligned line start addresses in the * chroma planes when IRT is used. Align to 8x8 pixel IRT block size * for all other formats.
*/ return (fmt->planar && !fmt->uv_packed) ? 8 * fmt->uv_width_dec : 8;
}
/* * Fill in left position and width and for all tiles in an input column, and * for all corresponding output tiles. If the 90° rotator is used, the output * tiles are in a row, and output tile top position and height are set.
*/ staticvoid fill_tile_column(struct ipu_image_convert_ctx *ctx, unsignedint col, struct ipu_image_convert_image *in, unsignedint in_left, unsignedint in_width, struct ipu_image_convert_image *out, unsignedint out_left, unsignedint out_width)
{ unsignedint row, tile_idx; struct ipu_image_tile *in_tile, *out_tile;
/* * Fill in top position and height and for all tiles in an input row, and * for all corresponding output tiles. If the 90° rotator is used, the output * tiles are in a column, and output tile left position and width are set.
*/ staticvoid fill_tile_row(struct ipu_image_convert_ctx *ctx, unsignedint row, struct ipu_image_convert_image *in, unsignedint in_top, unsignedint in_height, struct ipu_image_convert_image *out, unsignedint out_top, unsignedint out_height)
{ unsignedint col, tile_idx; struct ipu_image_tile *in_tile, *out_tile;
if (image->type == IMAGE_CONVERT_IN) { /* Up to 4096x4096 input tile size */
max_width <<= ctx->downsize_coeff_h;
max_height <<= ctx->downsize_coeff_v;
}
for (i = 0; i < ctx->num_tiles; i++) { struct ipu_image_tile *tile; constunsignedint row = i / image->num_cols; constunsignedint col = i % image->num_cols;
/* * Use the rotation transformation to find the tile coordinates * (row, col) of a tile in the destination frame that corresponds * to the given tile coordinates of a source frame. The destination * coordinate is then converted to a tile index.
*/ staticint transform_tile_index(struct ipu_image_convert_ctx *ctx, int src_row, int src_col)
{ struct ipu_image_convert_chan *chan = ctx->chan; struct ipu_image_convert_priv *priv = chan->priv; struct ipu_image_convert_image *s_image = &ctx->in; struct ipu_image_convert_image *d_image = &ctx->out; int dst_row, dst_col;
/* with no rotation it's a 1:1 mapping */ if (ctx->rot_mode == IPU_ROTATE_NONE) return src_row * s_image->num_cols + src_col;
/* * before doing the transform, first we have to translate * source row,col for an origin in the center of s_image
*/
src_row = src_row * 2 - (s_image->num_rows - 1);
src_col = src_col * 2 - (s_image->num_cols - 1);
/* do the rotation transform */ if (ctx->rot_mode & IPU_ROT_BIT_90) {
dst_col = -src_row;
dst_row = src_col;
} else {
dst_col = src_col;
dst_row = src_row;
}
/* apply flip */ if (ctx->rot_mode & IPU_ROT_BIT_HFLIP)
dst_col = -dst_col; if (ctx->rot_mode & IPU_ROT_BIT_VFLIP)
dst_row = -dst_row;
/* * Calculate the resizing ratio for the IC main processing section given input * size, fixed downsizing coefficient, and output size. * Either round to closest for the next tile's first pixel to minimize seams * and distortion (for all but right column / bottom row), or round down to * avoid sampling beyond the edges of the input image for this tile's last * pixel. * Returns the resizing coefficient, resizing ratio is 8192.0 / resize_coeff.
*/ static u32 calc_resize_coeff(u32 input_size, u32 downsize_coeff,
u32 output_size, bool allow_overshoot)
{
u32 downsized = input_size >> downsize_coeff;
/* * With the horizontal scaling factor known, round up resized * width (output width or height) to burst size.
*/
resized_width = round_up(resized_width, 8);
/* * Calculate input width from the last accessed input pixel * given resized width and scaling coefficients. Round up to * burst size.
*/
last_output = resized_width - 1; if (closest && ((last_output * resize_coeff_h) % 8192))
last_output++;
in_width = round_up(
(DIV_ROUND_UP(last_output * resize_coeff_h, 8192) + 1)
<< ctx->downsize_coeff_h, 8);
/* * With the vertical scaling factor known, round up resized * height (output width or height) to IDMAC limitations.
*/
resized_height = round_up(resized_height, 2);
/* * Calculate input width from the last accessed input pixel * given resized height and scaling coefficients. Align to * IDMAC restrictions.
*/
last_output = resized_height - 1; if (closest && ((last_output * resize_coeff_v) % 8192))
last_output++;
in_height = round_up(
(DIV_ROUND_UP(last_output * resize_coeff_v, 8192) + 1)
<< ctx->downsize_coeff_v, 2);
if (ipu_rot_mode_is_irt(ctx->rot_mode))
out_tile->width = resized_height; else
out_tile->height = resized_height;
in_tile->height = in_height;
}
ctx->resize_coeffs_v[row] = resize_coeff_v;
}
}
/* * return the number of runs in given queue (pending_q or done_q) * for this context. hold irqlock when calling.
*/ staticint get_run_count(struct ipu_image_convert_ctx *ctx, struct list_head *q)
{ struct ipu_image_convert_run *run; int count = 0;
lockdep_assert_held(&ctx->chan->irqlock);
list_for_each_entry(run, q, list) { if (run->ctx == ctx)
count++;
}
/* disable IC tasks and the channels */
ipu_ic_task_disable(chan->ic);
ipu_idmac_disable_channel(chan->in_chan);
ipu_idmac_disable_channel(chan->out_chan);
if (ipu_rot_mode_is_irt(ctx->rot_mode)) {
ipu_idmac_disable_channel(chan->rotation_in_chan);
ipu_idmac_disable_channel(chan->rotation_out_chan);
ipu_idmac_unlink(chan->out_chan, chan->rotation_in_chan);
}
if (rot_mode)
ipu_cpmem_set_rotation(channel, rot_mode);
/* * Skip writing U and V components to odd rows in the output * channels for planar 4:2:0.
*/ if ((channel == chan->out_chan ||
channel == chan->rotation_out_chan) &&
image->fmt->planar && image->fmt->uv_height_dec == 2)
ipu_cpmem_skip_odd_chroma_rows(channel);
/* * Setting a non-zero AXI ID collides with the PRG AXI snooping, so * only do this when there is no PRG present.
*/ if (!channel->ipu->prg_priv)
ipu_cpmem_set_axi_id(channel, 1);
/* remove run from pending_q and set as current */
list_del(&run->list);
chan->current_run = run;
return convert_start(run, 0);
}
/* hold irqlock when calling */ staticvoid run_next(struct ipu_image_convert_chan *chan)
{ struct ipu_image_convert_priv *priv = chan->priv; struct ipu_image_convert_run *run, *tmp; int ret;
lockdep_assert_held(&chan->irqlock);
list_for_each_entry_safe(run, tmp, &chan->pending_q, list) { /* skip contexts that are aborting */ if (run->ctx->aborting) {
dev_dbg(priv->ipu->dev, "%s: task %u: skipping aborting ctx %p run %p\n",
__func__, chan->ic_task, run->ctx, run); continue;
}
ret = do_run(run); if (!ret) break;
/* * something went wrong with start, add the run * to done q and continue to the next run in the * pending q.
*/
run->status = ret;
list_add_tail(&run->list, &chan->done_q);
chan->current_run = NULL;
}
}
while (!list_empty(&chan->done_q)) {
run = list_entry(chan->done_q.next, struct ipu_image_convert_run,
list);
list_del(&run->list);
dev_dbg(priv->ipu->dev, "%s: task %u: completing ctx %p run %p with %d\n",
__func__, chan->ic_task, run->ctx, run, run->status);
/* call the completion callback and free the run */
spin_unlock_irqrestore(&chan->irqlock, flags);
run->ctx->complete(run, run->ctx->complete_context);
spin_lock_irqsave(&chan->irqlock, flags);
}
spin_unlock_irqrestore(&chan->irqlock, flags);
}
/* * the bottom half thread clears out the done_q, calling the * completion handler for each.
*/ static irqreturn_t do_bh(int irq, void *dev_id)
{ struct ipu_image_convert_chan *chan = dev_id; struct ipu_image_convert_priv *priv = chan->priv; struct ipu_image_convert_ctx *ctx; unsignedlong flags;
/* * the done_q is cleared out, signal any contexts * that are aborting that abort can complete.
*/
list_for_each_entry(ctx, &chan->ctx_list, list) { if (ctx->aborting) {
dev_dbg(priv->ipu->dev, "%s: task %u: signaling abort for ctx %p\n",
__func__, chan->ic_task, ctx);
complete_all(&ctx->aborted);
}
}
/* * It is difficult to stop the channel DMA before the channels * enter the paused state. Without double-buffering the channels * are always in a paused state when the EOF irq occurs, so it * is safe to stop the channels now. For double-buffering we * just ignore the abort until the operation completes, when it * is safe to shut down.
*/ if (ctx->aborting && !ctx->double_buffering) {
convert_stop(run);
run->status = -EIO; goto done;
}
if (ctx->next_tile == ctx->num_tiles) { /* * the conversion is complete
*/
convert_stop(run);
run->status = 0; goto done;
}
/* * not done, place the next tile buffers.
*/ if (!ctx->double_buffering) { if (ic_settings_changed(ctx)) {
convert_stop(run);
convert_start(run, ctx->next_tile);
} else {
src_tile = &s_image->tile[ctx->next_tile];
dst_idx = ctx->out_tile_map[ctx->next_tile];
dst_tile = &d_image->tile[dst_idx];
ipu_cpmem_set_buffer(chan->in_chan, 0,
s_image->base.phys0 +
src_tile->offset);
ipu_cpmem_set_buffer(outch, 0,
d_image->base.phys0 +
dst_tile->offset); if (s_image->fmt->planar)
ipu_cpmem_set_uv_offset(chan->in_chan,
src_tile->u_off,
src_tile->v_off); if (d_image->fmt->planar)
ipu_cpmem_set_uv_offset(outch,
dst_tile->u_off,
dst_tile->v_off);
if (tile_complete)
ret = do_tile_complete(run);
out:
spin_unlock_irqrestore(&chan->irqlock, flags); return ret;
}
/* * try to force the completion of runs for this ctx. Called when * abort wait times out in ipu_image_convert_abort().
*/ staticvoid force_abort(struct ipu_image_convert_ctx *ctx)
{ struct ipu_image_convert_chan *chan = ctx->chan; struct ipu_image_convert_run *run; unsignedlong flags;
staticvoid release_ipu_resources(struct ipu_image_convert_chan *chan)
{ if (chan->in_eof_irq >= 0)
free_irq(chan->in_eof_irq, chan); if (chan->rot_in_eof_irq >= 0)
free_irq(chan->rot_in_eof_irq, chan); if (chan->out_eof_irq >= 0)
free_irq(chan->out_eof_irq, chan); if (chan->rot_out_eof_irq >= 0)
free_irq(chan->rot_out_eof_irq, chan);
if (!IS_ERR_OR_NULL(chan->in_chan))
ipu_idmac_put(chan->in_chan); if (!IS_ERR_OR_NULL(chan->out_chan))
ipu_idmac_put(chan->out_chan); if (!IS_ERR_OR_NULL(chan->rotation_in_chan))
ipu_idmac_put(chan->rotation_in_chan); if (!IS_ERR_OR_NULL(chan->rotation_out_chan))
ipu_idmac_put(chan->rotation_out_chan); if (!IS_ERR_OR_NULL(chan->ic))
ipu_ic_put(chan->ic);
/* get IC */
chan->ic = ipu_ic_get(priv->ipu, chan->ic_task); if (IS_ERR(chan->ic)) {
dev_err(priv->ipu->dev, "could not acquire IC\n");
ret = PTR_ERR(chan->ic); goto err;
}
/* get IDMAC channels */
chan->in_chan = ipu_idmac_get(priv->ipu, dma->in);
chan->out_chan = ipu_idmac_get(priv->ipu, dma->out); if (IS_ERR(chan->in_chan) || IS_ERR(chan->out_chan)) {
dev_err(priv->ipu->dev, "could not acquire idmac channels\n");
ret = -EBUSY; goto err;
}
chan->rotation_in_chan = ipu_idmac_get(priv->ipu, dma->rot_in);
chan->rotation_out_chan = ipu_idmac_get(priv->ipu, dma->rot_out); if (IS_ERR(chan->rotation_in_chan) || IS_ERR(chan->rotation_out_chan)) {
dev_err(priv->ipu->dev, "could not acquire idmac rotation channels\n");
ret = -EBUSY; goto err;
}
/* acquire the EOF interrupts */
ret = get_eof_irq(chan, chan->in_chan); if (ret < 0) {
chan->in_eof_irq = -1; goto err;
}
chan->in_eof_irq = ret;
ret = get_eof_irq(chan, chan->rotation_in_chan); if (ret < 0) {
chan->rot_in_eof_irq = -1; goto err;
}
chan->rot_in_eof_irq = ret;
ret = get_eof_irq(chan, chan->out_chan); if (ret < 0) {
chan->out_eof_irq = -1; goto err;
}
chan->out_eof_irq = ret;
ret = get_eof_irq(chan, chan->rotation_out_chan); if (ret < 0) {
chan->rot_out_eof_irq = -1; goto err;
}
chan->rot_out_eof_irq = ret;
ic_image->fmt = get_format(image->pix.pixelformat); if (!ic_image->fmt) {
dev_err(priv->ipu->dev, "pixelformat not supported for %s\n",
type == IMAGE_CONVERT_OUT ? "Output" : "Input"); return -EINVAL;
}
if (ic_image->fmt->planar)
ic_image->stride = ic_image->base.pix.width; else
ic_image->stride = ic_image->base.pix.bytesperline;
return 0;
}
/* borrowed from drivers/media/v4l2-core/v4l2-common.c */ staticunsignedint clamp_align(unsignedint x, unsignedint min, unsignedint max, unsignedint align)
{ /* Bits that must be zero to be aligned */ unsignedint mask = ~((1 << align) - 1);
/* Clamp to aligned min and max */
x = clamp(x, (min + ~mask) & mask, max & mask);
/* Round to nearest aligned value */ if (align)
x = (x + (1 << (align - 1))) & mask;
/* * this is used by ipu_image_convert_prepare() to verify set input and * output images are valid before starting the conversion. Clients can * also call it before calling ipu_image_convert_prepare().
*/ int ipu_image_convert_verify(struct ipu_image *in, struct ipu_image *out, enum ipu_rotate_mode rot_mode)
{ struct ipu_image testin, testout;
ret = fill_image(ctx, s_image, in, IMAGE_CONVERT_IN); if (ret) goto out_free;
ret = fill_image(ctx, d_image, out, IMAGE_CONVERT_OUT); if (ret) goto out_free;
calc_out_tile_map(ctx);
find_seams(ctx, s_image, d_image);
ret = calc_tile_dimensions(ctx, s_image); if (ret) goto out_free;
ret = calc_tile_offsets(ctx, s_image); if (ret) goto out_free;
calc_tile_dimensions(ctx, d_image);
ret = calc_tile_offsets(ctx, d_image); if (ret) goto out_free;
calc_tile_resize_coefficients(ctx);
ret = ipu_ic_calc_csc(&ctx->csc,
s_image->base.pix.ycbcr_enc,
s_image->base.pix.quantization,
ipu_pixelformat_to_colorspace(s_image->fmt->fourcc),
d_image->base.pix.ycbcr_enc,
d_image->base.pix.quantization,
ipu_pixelformat_to_colorspace(d_image->fmt->fourcc)); if (ret) goto out_free;
/* * Can we use double-buffering for this operation? If there is * only one tile (the whole image can be converted in a single * operation) there's no point in using double-buffering. Also, * the IPU's IDMAC channels allow only a single U and V plane * offset shared between both buffers, but these offsets change * for every tile, and therefore would have to be updated for * each buffer which is not possible. So double-buffering is * impossible when either the source or destination images are * a planar format (YUV420, YUV422P, etc.). Further, differently * sized tiles or different resizing coefficients per tile * prevent double-buffering as well.
*/
ctx->double_buffering = (ctx->num_tiles > 1 &&
!s_image->fmt->planar &&
!d_image->fmt->planar); for (i = 1; i < ctx->num_tiles; i++) { if (ctx->in.tile[i].width != ctx->in.tile[0].width ||
ctx->in.tile[i].height != ctx->in.tile[0].height ||
ctx->out.tile[i].width != ctx->out.tile[0].width ||
ctx->out.tile[i].height != ctx->out.tile[0].height) {
ctx->double_buffering = false; break;
}
} for (i = 1; i < ctx->in.num_cols; i++) { if (ctx->resize_coeffs_h[i] != ctx->resize_coeffs_h[0]) {
ctx->double_buffering = false; break;
}
} for (i = 1; i < ctx->in.num_rows; i++) { if (ctx->resize_coeffs_v[i] != ctx->resize_coeffs_v[0]) {
ctx->double_buffering = false; break;
}
}
if (ipu_rot_mode_is_irt(ctx->rot_mode)) { unsignedlong intermediate_size = d_image->tile[0].size;
for (i = 1; i < ctx->num_tiles; i++) { if (d_image->tile[i].size > intermediate_size)
intermediate_size = d_image->tile[i].size;
}
ret = alloc_dma_buf(priv, &ctx->rot_intermediate[0],
intermediate_size); if (ret) goto out_free; if (ctx->double_buffering) {
ret = alloc_dma_buf(priv,
&ctx->rot_intermediate[1],
intermediate_size); if (ret) goto out_free_dmabuf0;
}
}
spin_lock_irqsave(&chan->irqlock, flags);
get_res = list_empty(&chan->ctx_list);
list_add_tail(&ctx->list, &chan->ctx_list);
spin_unlock_irqrestore(&chan->irqlock, flags);
if (get_res) {
ret = get_ipu_resources(chan); if (ret) goto out_free_dmabuf1;
}
/* * Carry out a single image conversion run. Only the physaddr's of the input * and output image buffers are needed. The conversion context must have * been created previously with ipu_image_convert_prepare().
*/ int ipu_image_convert_queue(struct ipu_image_convert_run *run)
{ struct ipu_image_convert_chan *chan; struct ipu_image_convert_priv *priv; struct ipu_image_convert_ctx *ctx; unsignedlong flags; int ret = 0;
if (!run || !run->ctx || !run->in_phys || !run->out_phys) return -EINVAL;
if (!chan->current_run) {
ret = do_run(run); if (ret)
chan->current_run = NULL;
}
unlock:
spin_unlock_irqrestore(&chan->irqlock, flags); return ret;
}
EXPORT_SYMBOL_GPL(ipu_image_convert_queue);
/* Abort any active or pending conversions for this context */ staticvoid __ipu_image_convert_abort(struct ipu_image_convert_ctx *ctx)
{
--> --------------------
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.