예제 #1
0
static void jpeg_device_enc_run(void *priv)
{
	struct jpeg_ctx *ctx = priv;
	struct jpeg_dev *dev = ctx->dev;
	struct jpeg_enc_param enc_param;
	struct vb2_buffer *vb = NULL;
	unsigned long flags;

	dev = ctx->dev;
	spin_lock_irqsave(&ctx->dev->slock, flags);

	dev->mode = ENCODING;
	enc_param = ctx->param.enc_param;

	jpeg_sw_reset(dev->reg_base);
	jpeg_set_interrupt(dev->reg_base);
	jpeg_set_huf_table_enable(dev->reg_base, 1);
	jpeg_set_enc_tbl(dev->reg_base);
	jpeg_set_encode_tbl_select(dev->reg_base, enc_param.quality);
	jpeg_set_stream_size(dev->reg_base,
		enc_param.in_width, enc_param.in_height);
	jpeg_set_enc_out_fmt(dev->reg_base, enc_param.out_fmt);
	jpeg_set_enc_in_fmt(dev->reg_base, enc_param.in_fmt);
	vb = v4l2_m2m_next_dst_buf(ctx->m2m_ctx);
	jpeg_set_stream_buf_address(dev->reg_base, dev->vb2->plane_addr(vb, 0));

	vb = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
	if (enc_param.in_plane == 1)
		jpeg_set_frame_buf_address(dev->reg_base,
			enc_param.in_fmt, dev->vb2->plane_addr(vb, 0), 0, 0);
	if (enc_param.in_plane == 2)
		jpeg_set_frame_buf_address(dev->reg_base,
			enc_param.in_fmt, dev->vb2->plane_addr(vb, 0),
			dev->vb2->plane_addr(vb, 1), 0);
	if (enc_param.in_plane == 3)
		jpeg_set_frame_buf_address(dev->reg_base,
			enc_param.in_fmt, dev->vb2->plane_addr(vb, 0),
			dev->vb2->plane_addr(vb, 1), dev->vb2->plane_addr(vb, 2));

	jpeg_set_encode_hoff_cnt(dev->reg_base, enc_param.out_fmt);

	jpeg_set_enc_dec_mode(dev->reg_base, ENCODING);

	spin_unlock_irqrestore(&ctx->dev->slock, flags);
}
예제 #2
0
static int jpeg_1shotdev_device_run(struct m2m1shot_context *m21ctx,
                                    struct m2m1shot_task *task)
{
    struct jpeg_ctx *ctx = m21ctx->priv;
    struct jpeg_dev *jpeg = ctx->jpeg_dev;

    if (!jpeg) {
        pr_err("jpeg is null\n");
        return -EINVAL;
    }

    BUG_ON(test_bit(DEV_RUN, &jpeg->state));
    BUG_ON(test_bit(DEV_SUSPEND, &jpeg->state));
    BUG_ON(!test_bit(DEV_RUNTIME_RESUME, &jpeg->state));

    jpeg_sw_reset(jpeg->regs);
    jpeg_set_interrupt(jpeg->regs);

    jpeg_set_huf_table_enable(jpeg->regs, true);
    jpeg_set_stream_size(jpeg->regs, ctx->width, ctx->height);

    if (allow_custom_qtbl &&
            !!(ctx->flags & EXYNOS_JPEG_CTX_CUSTOM_QTBL) &&
            ctx->custom_qtbl) {
        jpeg_set_enc_custom_tbl(jpeg->regs, ctx->custom_qtbl);
    } else {
        jpeg_set_enc_tbl(jpeg->regs, ctx->quality);
    }

    jpeg_set_encode_tbl_select(jpeg->regs);
    jpeg_set_encode_huffman_table(jpeg->regs);

    jpeg_set_image_fmt(jpeg->regs, ctx->in_fmt->reg_cfg |
                       ctx->out_fmt->reg_cfg);

    if (is_jpeg_fmt(ctx->out_fmt->fourcc)) {
        jpeg_set_stream_addr(jpeg->regs,
                             task->dma_buf_cap.plane[0].dma_addr);
        jpeg_set_image_addr(jpeg->regs, &task->dma_buf_out,
                            ctx->in_fmt, ctx->width, ctx->height);
        jpeg_set_encode_hoff_cnt(jpeg->regs, ctx->out_fmt->fourcc);
    } else {
        jpeg_set_stream_addr(jpeg->regs,
                             task->dma_buf_out.plane[0].dma_addr);
        jpeg_set_image_addr(jpeg->regs, &task->dma_buf_cap,
                            ctx->out_fmt, ctx->width, ctx->height);
        jpeg_alpha_value_set(jpeg->regs, 0xff);
        jpeg_set_dec_bitstream_size(jpeg->regs,
                                    task->task.buf_out.plane[0].len);
    }

    set_bit(DEV_RUN, &jpeg->state);

    jpeg_set_timer_count(jpeg->regs, ctx->width * ctx->height * 8 + 0xff);

    if (is_jpeg_fmt(ctx->out_fmt->fourcc))
        jpeg_set_enc_dec_mode(jpeg->regs, ENCODING);
    else
        jpeg_set_enc_dec_mode(jpeg->regs, DECODING);

    return 0;
}