void gsc_hw_set_out_image_format(struct gsc_ctx *ctx) { struct gsc_dev *dev = ctx->gsc_dev; struct gsc_frame *frame = &ctx->d_frame; u32 i, depth = 0; u32 cfg; cfg = readl(dev->regs + GSC_OUT_CON); cfg &= ~(GSC_OUT_RGB_TYPE_MASK | GSC_OUT_YUV422_1P_ORDER_MASK | GSC_OUT_CHROMA_ORDER_MASK | GSC_OUT_FORMAT_MASK | GSC_OUT_CHROM_STRIDE_SEL_MASK | GSC_OUT_RB_SWAP_MASK); writel(cfg, dev->regs + GSC_OUT_CON); if (is_rgb(frame->fmt->pixelformat)) { gsc_hw_set_out_image_rgb(ctx); return; } if (ctx->out_path != GSC_DMA) { cfg |= GSC_OUT_YUV444; goto end_set; } for (i = 0; i < frame->fmt->num_planes; i++) depth += frame->fmt->depth[i]; switch (frame->fmt->nr_comp) { case 1: cfg |= GSC_OUT_YUV422_1P; if (frame->fmt->yorder == GSC_LSB_Y) cfg |= GSC_OUT_YUV422_1P_ORDER_LSB_Y; else cfg |= GSC_OUT_YUV422_1P_OEDER_LSB_C; if (frame->fmt->corder == GSC_CBCR && !rt_is_flag(GSC_REORDER)) cfg |= GSC_IN_CHROMA_ORDER_CBCR; else cfg |= GSC_IN_CHROMA_ORDER_CRCB; break; case 2: if (depth == 12) cfg |= GSC_OUT_YUV420_2P; else cfg |= GSC_OUT_YUV422_2P; if (frame->fmt->corder == GSC_CBCR && !rt_is_flag(GSC_REORDER)) cfg |= GSC_IN_CHROMA_ORDER_CBCR; else cfg |= GSC_IN_CHROMA_ORDER_CRCB; break; case 3: cfg |= GSC_OUT_YUV420_3P; break; }; if (is_AYV12(frame->fmt->pixelformat)) { cfg |= GSC_OUT_CHROM_STRIDE_SEPAR; gsc_hw_set_out_chrom_stride(ctx); } end_set: writel(cfg, dev->regs + GSC_OUT_CON); }
void gsc_hw_set_in_image_format(struct gsc_ctx *ctx) { struct gsc_dev *dev = ctx->gsc_dev; struct gsc_frame *frame = &ctx->s_frame; u32 i, depth = 0; u32 cfg; cfg = readl(dev->regs + GSC_IN_CON); cfg &= ~(GSC_IN_RGB_TYPE_MASK | GSC_IN_YUV422_1P_ORDER_MASK | GSC_IN_CHROMA_ORDER_MASK | GSC_IN_FORMAT_MASK | GSC_IN_TILE_TYPE_MASK | GSC_IN_TILE_MODE | GSC_IN_CHROM_STRIDE_SEL_MASK); writel(cfg, dev->regs + GSC_IN_CON); if (is_rgb(frame->fmt->pixelformat)) { gsc_hw_set_in_image_rgb(ctx); return; } for (i = 0; i < frame->fmt->num_planes; i++) depth += frame->fmt->depth[i]; switch (frame->fmt->nr_comp) { case 1: cfg |= GSC_IN_YUV422_1P; if (frame->fmt->yorder == GSC_LSB_Y) cfg |= GSC_IN_YUV422_1P_ORDER_LSB_Y; else cfg |= GSC_IN_YUV422_1P_OEDER_LSB_C; if (frame->fmt->corder == GSC_CBCR && !rt_is_flag(GSC_REORDER)) cfg |= GSC_IN_CHROMA_ORDER_CBCR; else cfg |= GSC_IN_CHROMA_ORDER_CRCB; break; case 2: if (depth == 12) cfg |= GSC_IN_YUV420_2P; else cfg |= GSC_IN_YUV422_2P; if (frame->fmt->corder == GSC_CBCR && !rt_is_flag(GSC_REORDER)) cfg |= GSC_IN_CHROMA_ORDER_CBCR; else cfg |= GSC_IN_CHROMA_ORDER_CRCB; break; case 3: if (depth == 12) cfg |= GSC_IN_YUV420_3P; else cfg |= GSC_IN_YUV422_3P; break; }; if (is_AYV12(frame->fmt->pixelformat)) gsc_hw_set_in_chrom_stride(ctx); if (is_tiled(frame->fmt)) cfg |= GSC_IN_TILE_C_16x8 | GSC_IN_TILE_MODE; writel(cfg, dev->regs + GSC_IN_CON); }