msm: mdss: rotator: validate ubwc x and y offsets
For destination roi x and y offsets need to be validated for ubwc formats to make sure that they align to the start of a tile. Change-Id: I43c50401a212b624851fa0d7f1347fe313d19ca2 Signed-off-by: Terence Hampson <thampson@codeaurora.org>
This commit is contained in:
parent
75c3748493
commit
fac0d37e2c
4 changed files with 57 additions and 7 deletions
|
@ -1198,6 +1198,8 @@ int mdss_mdp_get_rau_strides(u32 w, u32 h, struct mdss_mdp_format_params *fmt,
|
|||
void mdss_mdp_data_calc_offset(struct mdss_mdp_data *data, u16 x, u16 y,
|
||||
struct mdss_mdp_plane_sizes *ps, struct mdss_mdp_format_params *fmt);
|
||||
struct mdss_mdp_format_params *mdss_mdp_get_format_params(u32 format);
|
||||
int mdss_mdp_validate_offset_for_ubwc_format(
|
||||
struct mdss_mdp_format_params *fmt, u16 x, u16 y);
|
||||
void mdss_mdp_get_v_h_subsample_rate(u8 chroma_samp,
|
||||
u8 *v_sample, u8 *h_sample);
|
||||
struct mult_factor *mdss_mdp_get_comp_factor(u32 format,
|
||||
|
|
|
@ -31,7 +31,7 @@ enum {
|
|||
COLOR_ALPHA_4BIT = 1,
|
||||
};
|
||||
|
||||
#define UBWC_META_MACRO_W 16
|
||||
#define UBWC_META_MACRO_W_H 16
|
||||
#define UBWC_META_BLOCK_SIZE 256
|
||||
|
||||
#define FMT_RGB_565(fmt, fetch_type, flag_arg, e0, e1, e2) \
|
||||
|
|
|
@ -804,6 +804,32 @@ int mdss_mdp_data_check(struct mdss_mdp_data *data,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int mdss_mdp_validate_offset_for_ubwc_format(
|
||||
struct mdss_mdp_format_params *fmt, u16 x, u16 y)
|
||||
{
|
||||
int ret;
|
||||
u16 micro_w, micro_h;
|
||||
|
||||
ret = mdss_mdp_get_ubwc_micro_dim(fmt->format, µ_w, µ_h);
|
||||
if (ret || !micro_w || !micro_h) {
|
||||
pr_err("Could not get valid micro tile dimensions\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (x % (micro_w * UBWC_META_MACRO_W_H)) {
|
||||
pr_err("x=%d does not align with meta width=%d\n", x,
|
||||
micro_w * UBWC_META_MACRO_W_H);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (y % (UBWC_META_MACRO_W_H)) {
|
||||
pr_err("y=%d does not align with meta height=%d\n", y,
|
||||
UBWC_META_MACRO_W_H);
|
||||
return -EINVAL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* x and y are assumednt to be valid, expected to line up with start of tiles */
|
||||
void mdss_mdp_ubwc_data_calc_offset(struct mdss_mdp_data *data, u16 x, u16 y,
|
||||
struct mdss_mdp_plane_sizes *ps, struct mdss_mdp_format_params *fmt)
|
||||
|
@ -850,7 +876,7 @@ void mdss_mdp_ubwc_data_calc_offset(struct mdss_mdp_data *data, u16 x, u16 y,
|
|||
}
|
||||
|
||||
offset = (y / 8) * ps->ystride[2] +
|
||||
((x / micro_w) / UBWC_META_MACRO_W) *
|
||||
((x / micro_w) / UBWC_META_MACRO_W_H) *
|
||||
UBWC_META_BLOCK_SIZE;
|
||||
if (offset < data->p[2].len) {
|
||||
data->p[2].addr += offset;
|
||||
|
@ -860,7 +886,7 @@ void mdss_mdp_ubwc_data_calc_offset(struct mdss_mdp_data *data, u16 x, u16 y,
|
|||
}
|
||||
|
||||
offset = ((y / 2) / 8) * ps->ystride[3] +
|
||||
(((x / 2) / chroma_micro_w) / UBWC_META_MACRO_W) *
|
||||
(((x / 2) / chroma_micro_w) / UBWC_META_MACRO_W_H) *
|
||||
UBWC_META_BLOCK_SIZE;
|
||||
if (offset < data->p[3].len) {
|
||||
data->p[3].addr += offset;
|
||||
|
@ -880,7 +906,7 @@ void mdss_mdp_ubwc_data_calc_offset(struct mdss_mdp_data *data, u16 x, u16 y,
|
|||
}
|
||||
|
||||
offset = DIV_ROUND_UP(y, 8) * ps->ystride[2] +
|
||||
((x / micro_w) / UBWC_META_MACRO_W) *
|
||||
((x / micro_w) / UBWC_META_MACRO_W_H) *
|
||||
UBWC_META_BLOCK_SIZE;
|
||||
if (offset < data->p[2].len) {
|
||||
data->p[2].addr += offset;
|
||||
|
|
|
@ -1335,18 +1335,34 @@ static int mdss_rotator_validate_item_matches_session(
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Only need to validate x and y offset for ubwc dst fmt */
|
||||
static int mdss_rotator_validate_img_roi(struct mdp_rotation_item *item)
|
||||
{
|
||||
struct mdss_mdp_format_params *fmt;
|
||||
int ret = 0;
|
||||
|
||||
fmt = mdss_mdp_get_format_params(item->input.format);
|
||||
if (!fmt) {
|
||||
pr_err("invalid input format:%d\n", item->input.format);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (mdss_mdp_is_ubwc_format(fmt))
|
||||
ret = mdss_mdp_validate_offset_for_ubwc_format(fmt,
|
||||
item->dst_rect.x, item->dst_rect.y);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int mdss_rotator_validate_entry(struct mdss_rot_mgr *mgr,
|
||||
struct mdss_rot_file_private *private,
|
||||
struct mdss_rot_entry *entry)
|
||||
{
|
||||
int ret;
|
||||
u32 out_format, in_format;
|
||||
struct mdp_rotation_item *item;
|
||||
struct mdss_rot_perf *perf;
|
||||
|
||||
item = &entry->item;
|
||||
in_format = item->input.format;
|
||||
out_format = item->output.format;
|
||||
|
||||
if (item->wb_idx != item->pipe_idx) {
|
||||
pr_err("invalid writeback and pipe idx\n");
|
||||
|
@ -1372,6 +1388,12 @@ static int mdss_rotator_validate_entry(struct mdss_rot_mgr *mgr,
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = mdss_rotator_validate_img_roi(item);
|
||||
if (ret) {
|
||||
pr_err("Image roi is invalid\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = mdss_rotator_config_dnsc_factor(mgr, entry);
|
||||
if (ret) {
|
||||
pr_err("fail to configure downscale factor\n");
|
||||
|
|
Loading…
Add table
Reference in a new issue