| .. | .. |
|---|
| 15 | 15 | #define GET_GCD(n1, n2) \ |
|---|
| 16 | 16 | ({ \ |
|---|
| 17 | 17 | int i; \ |
|---|
| 18 | | - int gcd = 0; \ |
|---|
| 18 | + int gcd = 1; \ |
|---|
| 19 | 19 | for (i = 1; i <= (n1) && i <= (n2); i++) { \ |
|---|
| 20 | 20 | if ((n1) % i == 0 && (n2) % i == 0) \ |
|---|
| 21 | 21 | gcd = i; \ |
|---|
| .. | .. |
|---|
| 46 | 46 | return feature; |
|---|
| 47 | 47 | } |
|---|
| 48 | 48 | |
|---|
| 49 | +static bool rga_check_csc_constant(const struct rga_hw_data *data, struct rga_req *rga_base, |
|---|
| 50 | + uint32_t mode, uint32_t flag) |
|---|
| 51 | +{ |
|---|
| 52 | + if (mode & flag) |
|---|
| 53 | + return true; |
|---|
| 54 | + |
|---|
| 55 | + if ((rga_base->full_csc.flag & 0x1) && (data->feature & RGA_FULL_CSC)) |
|---|
| 56 | + return true; |
|---|
| 57 | + |
|---|
| 58 | + return false; |
|---|
| 59 | +} |
|---|
| 60 | + |
|---|
| 61 | +static bool rga_check_csc(const struct rga_hw_data *data, struct rga_req *rga_base) |
|---|
| 62 | +{ |
|---|
| 63 | + switch (rga_base->yuv2rgb_mode) { |
|---|
| 64 | + case 0x1: |
|---|
| 65 | + return rga_check_csc_constant(data, rga_base, |
|---|
| 66 | + data->csc_y2r_mode, RGA_MODE_CSC_BT601L); |
|---|
| 67 | + case 0x2: |
|---|
| 68 | + return rga_check_csc_constant(data, rga_base, |
|---|
| 69 | + data->csc_y2r_mode, RGA_MODE_CSC_BT601F); |
|---|
| 70 | + case 0x3: |
|---|
| 71 | + return rga_check_csc_constant(data, rga_base, |
|---|
| 72 | + data->csc_y2r_mode, RGA_MODE_CSC_BT709); |
|---|
| 73 | + case 0x1 << 2: |
|---|
| 74 | + return rga_check_csc_constant(data, rga_base, |
|---|
| 75 | + data->csc_r2y_mode, RGA_MODE_CSC_BT601F); |
|---|
| 76 | + case 0x2 << 2: |
|---|
| 77 | + return rga_check_csc_constant(data, rga_base, |
|---|
| 78 | + data->csc_r2y_mode, RGA_MODE_CSC_BT601L); |
|---|
| 79 | + case 0x3 << 2: |
|---|
| 80 | + return rga_check_csc_constant(data, rga_base, |
|---|
| 81 | + data->csc_r2y_mode, RGA_MODE_CSC_BT709); |
|---|
| 82 | + default: |
|---|
| 83 | + break; |
|---|
| 84 | + } |
|---|
| 85 | + |
|---|
| 86 | + if ((rga_base->full_csc.flag & 0x1)) { |
|---|
| 87 | + if (data->feature & RGA_FULL_CSC) |
|---|
| 88 | + return true; |
|---|
| 89 | + else |
|---|
| 90 | + return false; |
|---|
| 91 | + } |
|---|
| 92 | + |
|---|
| 93 | + return true; |
|---|
| 94 | +} |
|---|
| 95 | + |
|---|
| 49 | 96 | static bool rga_check_resolution(const struct rga_rect_range *range, int width, int height) |
|---|
| 50 | 97 | { |
|---|
| 51 | 98 | if (width > range->max.width || height > range->max.height) |
|---|
| .. | .. |
|---|
| 61 | 108 | int rd_mode, int format, int win_num) |
|---|
| 62 | 109 | { |
|---|
| 63 | 110 | int i; |
|---|
| 64 | | - bool matched = false; |
|---|
| 111 | + const uint32_t *formats; |
|---|
| 112 | + uint32_t format_count; |
|---|
| 65 | 113 | |
|---|
| 66 | | - if (rd_mode == RGA_RASTER_MODE) { |
|---|
| 67 | | - for (i = 0; i < data->win[win_num].num_of_raster_formats; i++) { |
|---|
| 68 | | - if (format == data->win[win_num].raster_formats[i]) { |
|---|
| 69 | | - matched = true; |
|---|
| 70 | | - break; |
|---|
| 71 | | - } |
|---|
| 72 | | - } |
|---|
| 73 | | - } else if (rd_mode == RGA_FBC_MODE) { |
|---|
| 74 | | - for (i = 0; i < data->win[win_num].num_of_fbc_formats; i++) { |
|---|
| 75 | | - if (format == data->win[win_num].fbc_formats[i]) { |
|---|
| 76 | | - matched = true; |
|---|
| 77 | | - break; |
|---|
| 78 | | - } |
|---|
| 79 | | - } |
|---|
| 80 | | - } else if (rd_mode == RGA_TILE_MODE) { |
|---|
| 81 | | - for (i = 0; i < data->win[win_num].num_of_tile_formats; i++) { |
|---|
| 82 | | - if (format == data->win[win_num].tile_formats[i]) { |
|---|
| 83 | | - matched = true; |
|---|
| 84 | | - break; |
|---|
| 85 | | - } |
|---|
| 86 | | - } |
|---|
| 114 | + switch (rd_mode) { |
|---|
| 115 | + case RGA_RASTER_MODE: |
|---|
| 116 | + formats = data->win[win_num].formats[RGA_RASTER_INDEX]; |
|---|
| 117 | + format_count = data->win[win_num].formats_count[RGA_RASTER_INDEX]; |
|---|
| 118 | + break; |
|---|
| 119 | + case RGA_FBC_MODE: |
|---|
| 120 | + formats = data->win[win_num].formats[RGA_AFBC16x16_INDEX]; |
|---|
| 121 | + format_count = data->win[win_num].formats_count[RGA_AFBC16x16_INDEX]; |
|---|
| 122 | + break; |
|---|
| 123 | + case RGA_TILE_MODE: |
|---|
| 124 | + formats = data->win[win_num].formats[RGA_TILE8x8_INDEX]; |
|---|
| 125 | + format_count = data->win[win_num].formats_count[RGA_TILE8x8_INDEX]; |
|---|
| 126 | + break; |
|---|
| 127 | + default: |
|---|
| 128 | + return false; |
|---|
| 87 | 129 | } |
|---|
| 88 | 130 | |
|---|
| 89 | | - return matched; |
|---|
| 131 | + if (formats == NULL || format_count == 0) |
|---|
| 132 | + return false; |
|---|
| 133 | + |
|---|
| 134 | + for (i = 0; i < format_count; i++) |
|---|
| 135 | + if (format == formats[i]) |
|---|
| 136 | + return true; |
|---|
| 137 | + |
|---|
| 138 | + return false; |
|---|
| 90 | 139 | } |
|---|
| 91 | 140 | |
|---|
| 92 | 141 | static bool rga_check_align(uint32_t byte_stride_align, uint32_t format, uint16_t w_stride) |
|---|
| .. | .. |
|---|
| 118 | 167 | if (!rga_check_resolution(&data->input_range, src0->act_w, src0->act_h)) |
|---|
| 119 | 168 | return false; |
|---|
| 120 | 169 | |
|---|
| 170 | + if (data == &rga3_data && |
|---|
| 171 | + !rga_check_resolution(&data->input_range, |
|---|
| 172 | + src0->act_w + src0->x_offset, |
|---|
| 173 | + src0->act_h + src0->y_offset)) |
|---|
| 174 | + return false; |
|---|
| 175 | + |
|---|
| 121 | 176 | if (!rga_check_format(data, src0->rd_mode, src0->format, 0)) |
|---|
| 122 | 177 | return false; |
|---|
| 123 | 178 | |
|---|
| .. | .. |
|---|
| 133 | 188 | if (!rga_check_resolution(&data->input_range, src1->act_w, src1->act_h)) |
|---|
| 134 | 189 | return false; |
|---|
| 135 | 190 | |
|---|
| 191 | + if (data == &rga3_data && |
|---|
| 192 | + !rga_check_resolution(&data->input_range, |
|---|
| 193 | + src1->act_w + src1->x_offset, |
|---|
| 194 | + src1->act_h + src1->y_offset)) |
|---|
| 195 | + return false; |
|---|
| 196 | + |
|---|
| 136 | 197 | if (!rga_check_format(data, src1->rd_mode, src1->format, 1)) |
|---|
| 137 | 198 | return false; |
|---|
| 138 | 199 | |
|---|
| .. | .. |
|---|
| 146 | 207 | struct rga_img_info_t *dst) |
|---|
| 147 | 208 | { |
|---|
| 148 | 209 | if (!rga_check_resolution(&data->output_range, dst->act_w, dst->act_h)) |
|---|
| 210 | + return false; |
|---|
| 211 | + |
|---|
| 212 | + if (data == &rga3_data && |
|---|
| 213 | + !rga_check_resolution(&data->output_range, |
|---|
| 214 | + dst->act_w + dst->x_offset, |
|---|
| 215 | + dst->act_h + dst->y_offset)) |
|---|
| 149 | 216 | return false; |
|---|
| 150 | 217 | |
|---|
| 151 | 218 | if (!rga_check_format(data, dst->rd_mode, dst->format, 2)) |
|---|
| .. | .. |
|---|
| 306 | 373 | continue; |
|---|
| 307 | 374 | } |
|---|
| 308 | 375 | |
|---|
| 376 | + if (!rga_check_csc(data, rga_base)) { |
|---|
| 377 | + if (DEBUGGER_EN(MSG)) |
|---|
| 378 | + pr_info("core = %d, break on rga_check_csc", |
|---|
| 379 | + scheduler->core); |
|---|
| 380 | + continue; |
|---|
| 381 | + } |
|---|
| 382 | + |
|---|
| 309 | 383 | optional_cores |= scheduler->core; |
|---|
| 310 | 384 | } |
|---|
| 311 | 385 | |
|---|