// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) STMicroelectronics SA 2014
* Authors: Fabien Dessenne <fabien.dessenne@st.com> for STMicroelectronics.
*/
#include <linux/delay.h>
#include "bdisp.h"
#include "bdisp-filter.h"
#include "bdisp-reg.h"
/* Max width of the source frame in a single node */
#define MAX_SRC_WIDTH 2048
/* Reset & boot poll config */
#define POLL_RST_MAX 500
#define POLL_RST_DELAY_MS 2
enum bdisp_target_plan {
BDISP_RGB,
BDISP_Y,
BDISP_CBCR
};
struct bdisp_op_cfg {
bool cconv; /* RGB - YUV conversion */
bool hflip; /* Horizontal flip */
bool vflip; /* Vertical flip */
bool wide; /* Wide (>MAX_SRC_WIDTH) */
bool scale; /* Scale */
u16 h_inc; /* Horizontal increment in 6.10 format */
u16 v_inc; /* Vertical increment in 6.10 format */
bool src_interlaced; /* is the src an interlaced buffer */
u8 src_nbp; /* nb of planes of the src */
bool src_yuv; /* is the src a YUV color format */
bool src_420; /* is the src 4:2:0 chroma subsampled */
u8 dst_nbp; /* nb of planes of the dst */
bool dst_yuv; /* is the dst a YUV color format */
bool dst_420; /* is the dst 4:2:0 chroma subsampled */
};
struct bdisp_filter_addr {
u16 min; /* Filter min scale factor (6.10 fixed point) */
u16 max; /* Filter max scale factor (6.10 fixed point) */
void *virt; /* Virtual address for filter table */
dma_addr_t paddr; /* Physical address for filter table */
};
static const struct bdisp_filter_h_spec bdisp_h_spec[] = {
{
.min = 0,
.max = 921,
.coef = {
0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
0x00, 0x00, 0xff, 0x07, 0x3d, 0xfc, 0x01, 0x00,
0x00, 0x01, 0xfd, 0x11, 0x36, 0xf9, 0x02, 0x00,
0x00, 0x01, 0xfb, 0x1b, 0x2e, 0xf9, 0x02, 0x00,
0x00, 0x01, 0xf9, 0x26, 0x26, 0xf9, 0x01, 0x00,
0x00, 0x02, 0xf9, 0x30, 0x19, 0xfb, 0x01, 0x00,
0x00, 0x02, 0xf9, 0x39, 0x0e, 0xfd, 0x01, 0x00,
0x00, 0x01, 0xfc, 0x3e, 0x06, 0xff, 0x00, 0x00
}
},
{
.min = 921,
.max = 1024,
.coef = {
0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
0xff, 0x03, 0xfd, 0x08, 0x3e, 0xf9, 0x04, 0xfe,
0xfd, 0x06, 0xf8, 0x13, 0x3b, 0xf4, 0x07, 0xfc,
0xfb, 0x08, 0xf5, 0x1f, 0x34, 0xf1, 0x09, 0xfb,
0xfb, 0x09, 0xf2, 0x2b, 0x2a, 0xf1, 0x09, 0xfb,
0xfb, 0x09, 0xf2, 0x35, 0x1e, 0xf4, 0x08, 0xfb,
0xfc, 0x07, 0xf5, 0x3c, 0x12, 0xf7, 0x06, 0xfd,
0xfe, 0x04, 0xfa, 0x3f, 0x07, 0xfc, 0x03, 0xff
}
},
{
.min = 1024,
.max = 1126,
.coef = {
0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
0xff, 0x03, 0xfd, 0x08, 0x3e,