Commit 1804eacc authored by Ville Syrjälä's avatar Ville Syrjälä

sna: Add sna_br13_color_depth()

Refactor the BR13 color depth setup to common helper. This
eliminates a bunch of implicit fall through warns.
Signed-off-by: Ville Syrjälä's avatarVille Syrjälä <ville.syrjala@linux.intel.com>
parent 8cad9980
......@@ -8148,13 +8148,9 @@ kgem_replace_bo(struct kgem *kgem,
}
br13 |= 0xcc << 16;
switch (bpp) {
default:
case 32: br00 |= BLT_WRITE_ALPHA | BLT_WRITE_RGB;
br13 |= 1 << 25; /* RGB8888 */
case 16: br13 |= 1 << 24; /* RGB565 */
case 8: break;
}
br13 |= sna_br13_color_depth(bpp);
if (bpp == 32)
br00 |= BLT_WRITE_ALPHA | BLT_WRITE_RGB;
b = kgem->batch + kgem->nbatch;
if (kgem->gen >= 0100) {
......
......@@ -1397,4 +1397,23 @@ static inline void add_shm_flush(struct sna *sna, struct sna_pixmap *priv)
sna->needs_shm_flush = true;
}
static inline uint32_t sna_br13_color_depth(int bpp)
{
uint32_t br13 = 0;
switch (bpp) {
default:
assert(0);
/* fall through */
case 32:
br13 |= 1 << 25; /* RGB8888 */
/* fall through */
case 16:
br13 |= 1 << 24; /* RGB565 */
/* fall through */
case 8:
return br13;
}
}
#endif /* _SNA_H */
......@@ -154,12 +154,7 @@ static bool sna_blt_fill_init(struct sna *sna,
}
blt->br13 |= 1<<31 | (fill_ROP[alu] << 16);
switch (bpp) {
default: assert(0);
case 32: blt->br13 |= 1 << 25; /* RGB8888 */
case 16: blt->br13 |= 1 << 24; /* RGB565 */
case 8: break;
}
blt->br13 |= sna_br13_color_depth(bpp);
blt->pixel = pixel;
blt->bpp = bpp;
......@@ -372,12 +367,7 @@ static bool sna_blt_copy_init(struct sna *sna,
blt->overwrites = alu == GXcopy || alu == GXclear || alu == GXset;
blt->br13 = (copy_ROP[alu] << 16) | blt->pitch[1];
switch (bpp) {
default: assert(0);
case 32: blt->br13 |= 1 << 25; /* RGB8888 */
case 16: blt->br13 |= 1 << 24; /* RGB565 */
case 8: break;
}
blt->br13 |= sna_br13_color_depth(bpp);
kgem_set_mode(kgem, KGEM_BLT, dst);
if (!kgem_check_many_bo_fenced(kgem, src, dst, NULL)) {
......@@ -425,13 +415,10 @@ static bool sna_blt_alpha_fixup_init(struct sna *sna,
blt->overwrites = 1;
blt->br13 = (0xfc << 16) | blt->pitch[1];
switch (bpp) {
default: assert(0);
case 32: blt->cmd |= BLT_WRITE_ALPHA | BLT_WRITE_RGB;
blt->br13 |= 1 << 25; /* RGB8888 */
case 16: blt->br13 |= 1 << 24; /* RGB565 */
case 8: break;
}
blt->br13 |= sna_br13_color_depth(bpp);
if (bpp == 32)
blt->cmd |= BLT_WRITE_ALPHA | BLT_WRITE_RGB;
blt->pixel = alpha;
kgem_set_mode(kgem, KGEM_BLT, dst);
......@@ -3356,13 +3343,9 @@ static bool sna_blt_fill_box(struct sna *sna, uint8_t alu,
assert(br13 <= MAXSHORT);
br13 |= fill_ROP[alu] << 16;
switch (bpp) {
default: assert(0);
case 32: cmd |= BLT_WRITE_ALPHA | BLT_WRITE_RGB;
br13 |= 1 << 25; /* RGB8888 */
case 16: br13 |= 1 << 24; /* RGB565 */
case 8: break;
}
br13 |= sna_br13_color_depth(bpp);
if (bpp == 32)
cmd |= BLT_WRITE_ALPHA | BLT_WRITE_RGB;
/* All too frequently one blt completely overwrites the previous */
overwrites = alu == GXcopy || alu == GXclear || alu == GXset;
......@@ -3517,12 +3500,7 @@ bool sna_blt_fill_boxes(struct sna *sna, uint8_t alu,
assert(br13 <= MAXSHORT);
br13 |= 1<<31 | fill_ROP[alu] << 16;
switch (bpp) {
default: assert(0);
case 32: br13 |= 1 << 25; /* RGB8888 */
case 16: br13 |= 1 << 24; /* RGB565 */
case 8: break;
}
br13 |= sna_br13_color_depth(bpp);
kgem_set_mode(kgem, KGEM_BLT, bo);
if (!kgem_check_batch(kgem, 14) ||
......@@ -3739,12 +3717,7 @@ bool sna_blt_copy_boxes(struct sna *sna, uint8_t alu,
assert(br13 <= MAXSHORT);
br13 |= copy_ROP[alu] << 16;
switch (bpp) {
default: assert(0);
case 32: br13 |= 1 << 25; /* RGB8888 */
case 16: br13 |= 1 << 24; /* RGB565 */
case 8: break;
}
br13 |= sna_br13_color_depth(bpp);
/* Compare first box against a previous fill */
if ((alu == GXcopy || alu == GXclear || alu == GXset) &&
......@@ -4086,12 +4059,7 @@ bool sna_blt_copy_boxes__with_alpha(struct sna *sna, uint8_t alu,
assert(br13 <= MAXSHORT);
br13 |= copy_ROP[alu] << 16;
switch (bpp) {
default: assert(0);
case 32: br13 |= 1 << 25; /* RGB8888 */
case 16: br13 |= 1 << 24; /* RGB565 */
case 8: break;
}
br13 |= sna_br13_color_depth(bpp);
kgem_set_mode(kgem, KGEM_BLT, dst_bo);
if (!kgem_check_many_bo_fenced(kgem, dst_bo, src_bo, NULL)) {
......
......@@ -465,13 +465,9 @@ fallback:
}
br13 = 0xcc << 16;
switch (cpp) {
default:
case 4: cmd |= BLT_WRITE_ALPHA | BLT_WRITE_RGB;
br13 |= 1 << 25; /* RGB8888 */
case 2: br13 |= 1 << 24; /* RGB565 */
case 1: break;
}
br13 |= sna_br13_color_depth(cpp * 4);
if (cpp == 4)
cmd |= BLT_WRITE_ALPHA | BLT_WRITE_RGB;
kgem_set_mode(kgem, KGEM_BLT, dst_bo);
if (!kgem_check_batch(kgem, 10) ||
......@@ -1042,13 +1038,9 @@ tile:
br13 >>= 2;
}
br13 |= 0xcc << 16;
switch (dst->drawable.bitsPerPixel) {
default:
case 32: cmd |= BLT_WRITE_ALPHA | BLT_WRITE_RGB;
br13 |= 1 << 25; /* RGB8888 */
case 16: br13 |= 1 << 24; /* RGB565 */
case 8: break;
}
br13 |= sna_br13_color_depth(dst->drawable.bitsPerPixel);
if (dst->drawable.bitsPerPixel == 32)
cmd |= BLT_WRITE_ALPHA | BLT_WRITE_RGB;
kgem_set_mode(kgem, KGEM_BLT, dst_bo);
if (!kgem_check_batch(kgem, 10) ||
......@@ -1548,13 +1540,9 @@ tile:
br13 >>= 2;
}
br13 |= 0xcc << 16;
switch (dst->drawable.bitsPerPixel) {
default:
case 32: cmd |= BLT_WRITE_ALPHA | BLT_WRITE_RGB;
br13 |= 1 << 25; /* RGB8888 */
case 16: br13 |= 1 << 24; /* RGB565 */
case 8: break;
}
br13 |= sna_br13_color_depth(dst->drawable.bitsPerPixel);
if (dst->drawable.bitsPerPixel == 32)
cmd |= BLT_WRITE_ALPHA | BLT_WRITE_RGB;
kgem_set_mode(kgem, KGEM_BLT, dst_bo);
if (!kgem_check_batch(kgem, 10) ||
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment