Commit fe3cc9d6 authored by Tomi Valkeinen's avatar Tomi Valkeinen

OMAP: DSS2: DISPC: use lookup tables for bit shifts

Use lookup tables instead of switch/if in some DISPC functions to make
the code cleaner.
Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
Acked-by: default avatarArchit Taneja <archit@ti.com>
parent 4a9e78ab
...@@ -737,6 +737,9 @@ static void _dispc_set_pre_mult_alpha(enum omap_plane plane, bool enable) ...@@ -737,6 +737,9 @@ static void _dispc_set_pre_mult_alpha(enum omap_plane plane, bool enable)
static void _dispc_setup_global_alpha(enum omap_plane plane, u8 global_alpha) static void _dispc_setup_global_alpha(enum omap_plane plane, u8 global_alpha)
{ {
static const unsigned shifts[] = { 0, 8, 16, };
int shift;
if (!dss_has_feature(FEAT_GLOBAL_ALPHA)) if (!dss_has_feature(FEAT_GLOBAL_ALPHA))
return; return;
...@@ -744,10 +747,8 @@ static void _dispc_setup_global_alpha(enum omap_plane plane, u8 global_alpha) ...@@ -744,10 +747,8 @@ static void _dispc_setup_global_alpha(enum omap_plane plane, u8 global_alpha)
plane == OMAP_DSS_VIDEO1) plane == OMAP_DSS_VIDEO1)
return; return;
if (plane == OMAP_DSS_GFX) shift = shifts[plane];
REG_FLD_MOD(DISPC_GLOBAL_ALPHA, global_alpha, 7, 0); REG_FLD_MOD(DISPC_GLOBAL_ALPHA, global_alpha, shift + 7, shift);
else if (plane == OMAP_DSS_VIDEO2)
REG_FLD_MOD(DISPC_GLOBAL_ALPHA, global_alpha, 23, 16);
} }
static void _dispc_set_pix_inc(enum omap_plane plane, s32 inc) static void _dispc_set_pix_inc(enum omap_plane plane, s32 inc)
...@@ -891,21 +892,10 @@ static void dispc_set_channel_out(enum omap_plane plane, ...@@ -891,21 +892,10 @@ static void dispc_set_channel_out(enum omap_plane plane,
static void dispc_set_burst_size(enum omap_plane plane, static void dispc_set_burst_size(enum omap_plane plane,
enum omap_burst_size burst_size) enum omap_burst_size burst_size)
{ {
static const unsigned shifts[] = { 6, 14, 14, };
int shift; int shift;
switch (plane) { shift = shifts[plane];
case OMAP_DSS_GFX:
shift = 6;
break;
case OMAP_DSS_VIDEO1:
case OMAP_DSS_VIDEO2:
shift = 14;
break;
default:
BUG();
return;
}
REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), burst_size, shift + 1, shift); REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), burst_size, shift + 1, shift);
} }
...@@ -987,14 +977,11 @@ static void _dispc_set_vid_color_conv(enum omap_plane plane, bool enable) ...@@ -987,14 +977,11 @@ static void _dispc_set_vid_color_conv(enum omap_plane plane, bool enable)
void dispc_enable_replication(enum omap_plane plane, bool enable) void dispc_enable_replication(enum omap_plane plane, bool enable)
{ {
int bit; static const unsigned shifts[] = { 5, 10, 10 };
int shift;
if (plane == OMAP_DSS_GFX)
bit = 5;
else
bit = 10;
REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), enable, bit, bit); shift = shifts[plane];
REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), enable, shift, shift);
} }
void dispc_set_lcd_size(enum omap_channel channel, u16 width, u16 height) void dispc_set_lcd_size(enum omap_channel channel, u16 width, u16 height)
...@@ -3044,6 +3031,17 @@ static void dispc_error_worker(struct work_struct *work) ...@@ -3044,6 +3031,17 @@ static void dispc_error_worker(struct work_struct *work)
int i; int i;
u32 errors; u32 errors;
unsigned long flags; unsigned long flags;
static const unsigned fifo_underflow_bits[] = {
DISPC_IRQ_GFX_FIFO_UNDERFLOW,
DISPC_IRQ_VID1_FIFO_UNDERFLOW,
DISPC_IRQ_VID2_FIFO_UNDERFLOW,
};
static const unsigned sync_lost_bits[] = {
DISPC_IRQ_SYNC_LOST,
DISPC_IRQ_SYNC_LOST_DIGIT,
DISPC_IRQ_SYNC_LOST2,
};
spin_lock_irqsave(&dispc.irq_lock, flags); spin_lock_irqsave(&dispc.irq_lock, flags);
errors = dispc.error_irqs; errors = dispc.error_irqs;
...@@ -3052,154 +3050,52 @@ static void dispc_error_worker(struct work_struct *work) ...@@ -3052,154 +3050,52 @@ static void dispc_error_worker(struct work_struct *work)
dispc_runtime_get(); dispc_runtime_get();
if (errors & DISPC_IRQ_GFX_FIFO_UNDERFLOW) { for (i = 0; i < omap_dss_get_num_overlays(); ++i) {
DSSERR("GFX_FIFO_UNDERFLOW, disabling GFX\n"); struct omap_overlay *ovl;
for (i = 0; i < omap_dss_get_num_overlays(); ++i) { unsigned bit;
struct omap_overlay *ovl;
ovl = omap_dss_get_overlay(i);
if (ovl->id == 0) {
dispc_enable_plane(ovl->id, 0);
dispc_go(ovl->manager->id);
mdelay(50);
break;
}
}
}
if (errors & DISPC_IRQ_VID1_FIFO_UNDERFLOW) {
DSSERR("VID1_FIFO_UNDERFLOW, disabling VID1\n");
for (i = 0; i < omap_dss_get_num_overlays(); ++i) {
struct omap_overlay *ovl;
ovl = omap_dss_get_overlay(i);
if (ovl->id == 1) {
dispc_enable_plane(ovl->id, 0);
dispc_go(ovl->manager->id);
mdelay(50);
break;
}
}
}
if (errors & DISPC_IRQ_VID2_FIFO_UNDERFLOW) {
DSSERR("VID2_FIFO_UNDERFLOW, disabling VID2\n");
for (i = 0; i < omap_dss_get_num_overlays(); ++i) {
struct omap_overlay *ovl;
ovl = omap_dss_get_overlay(i);
if (ovl->id == 2) {
dispc_enable_plane(ovl->id, 0);
dispc_go(ovl->manager->id);
mdelay(50);
break;
}
}
}
if (errors & DISPC_IRQ_SYNC_LOST) {
struct omap_overlay_manager *manager = NULL;
bool enable = false;
DSSERR("SYNC_LOST, disabling LCD\n");
for (i = 0; i < omap_dss_get_num_overlay_managers(); ++i) {
struct omap_overlay_manager *mgr;
mgr = omap_dss_get_overlay_manager(i);
if (mgr->id == OMAP_DSS_CHANNEL_LCD) { ovl = omap_dss_get_overlay(i);
manager = mgr; bit = fifo_underflow_bits[i];
enable = mgr->device->state ==
OMAP_DSS_DISPLAY_ACTIVE;
mgr->device->driver->disable(mgr->device);
break;
}
}
if (manager) { if (bit & errors) {
struct omap_dss_device *dssdev = manager->device; DSSERR("FIFO UNDERFLOW on %s, disabling the overlay\n",
for (i = 0; i < omap_dss_get_num_overlays(); ++i) { ovl->name);
struct omap_overlay *ovl; dispc_enable_plane(ovl->id, false);
ovl = omap_dss_get_overlay(i); dispc_go(ovl->manager->id);
if (ovl->id != 0 && ovl->manager == manager)
dispc_enable_plane(ovl->id, 0);
}
dispc_go(manager->id);
mdelay(50); mdelay(50);
if (enable)
dssdev->driver->enable(dssdev);
} }
} }
if (errors & DISPC_IRQ_SYNC_LOST_DIGIT) { for (i = 0; i < omap_dss_get_num_overlay_managers(); ++i) {
struct omap_overlay_manager *manager = NULL; struct omap_overlay_manager *mgr;
bool enable = false; unsigned bit;
DSSERR("SYNC_LOST_DIGIT, disabling TV\n");
for (i = 0; i < omap_dss_get_num_overlay_managers(); ++i) {
struct omap_overlay_manager *mgr;
mgr = omap_dss_get_overlay_manager(i);
if (mgr->id == OMAP_DSS_CHANNEL_DIGIT) {
manager = mgr;
enable = mgr->device->state ==
OMAP_DSS_DISPLAY_ACTIVE;
mgr->device->driver->disable(mgr->device);
break;
}
}
if (manager) {
struct omap_dss_device *dssdev = manager->device;
for (i = 0; i < omap_dss_get_num_overlays(); ++i) {
struct omap_overlay *ovl;
ovl = omap_dss_get_overlay(i);
if (ovl->id != 0 && ovl->manager == manager) mgr = omap_dss_get_overlay_manager(i);
dispc_enable_plane(ovl->id, 0); bit = sync_lost_bits[i];
}
dispc_go(manager->id); if (bit & errors) {
mdelay(50); struct omap_dss_device *dssdev = mgr->device;
if (enable) bool enable;
dssdev->driver->enable(dssdev);
}
}
if (errors & DISPC_IRQ_SYNC_LOST2) {
struct omap_overlay_manager *manager = NULL;
bool enable = false;
DSSERR("SYNC_LOST for LCD2, disabling LCD2\n");
for (i = 0; i < omap_dss_get_num_overlay_managers(); ++i) { DSSERR("SYNC_LOST on channel %s, restarting the output "
struct omap_overlay_manager *mgr; "with video overlays disabled\n",
mgr = omap_dss_get_overlay_manager(i); mgr->name);
if (mgr->id == OMAP_DSS_CHANNEL_LCD2) { enable = dssdev->state == OMAP_DSS_DISPLAY_ACTIVE;
manager = mgr; dssdev->driver->disable(dssdev);
enable = mgr->device->state ==
OMAP_DSS_DISPLAY_ACTIVE;
mgr->device->driver->disable(mgr->device);
break;
}
}
if (manager) {
struct omap_dss_device *dssdev = manager->device;
for (i = 0; i < omap_dss_get_num_overlays(); ++i) { for (i = 0; i < omap_dss_get_num_overlays(); ++i) {
struct omap_overlay *ovl; struct omap_overlay *ovl;
ovl = omap_dss_get_overlay(i); ovl = omap_dss_get_overlay(i);
if (ovl->id != 0 && ovl->manager == manager) if (ovl->id != OMAP_DSS_GFX &&
dispc_enable_plane(ovl->id, 0); ovl->manager == mgr)
dispc_enable_plane(ovl->id, false);
} }
dispc_go(manager->id); dispc_go(mgr->id);
mdelay(50); mdelay(50);
if (enable) if (enable)
dssdev->driver->enable(dssdev); dssdev->driver->enable(dssdev);
} }
......
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