aboutsummaryrefslogtreecommitdiffstats
path: root/src/gamma-drm.c
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2025-03-05 20:36:07 +0100
committerMattias Andrée <m@maandree.se>2025-03-05 20:36:07 +0100
commit61821405d8f48117b82ce839c7196eb68c2d8266 (patch)
tree8255c88a57d6ec4771284809763349f61267356f /src/gamma-drm.c
parentJust use double, no mixing in float (diff)
downloadredshift-ng-61821405d8f48117b82ce839c7196eb68c2d8266.tar.gz
redshift-ng-61821405d8f48117b82ce839c7196eb68c2d8266.tar.bz2
redshift-ng-61821405d8f48117b82ce839c7196eb68c2d8266.tar.xz
Style and warnings
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'src/gamma-drm.c')
-rw-r--r--src/gamma-drm.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/gamma-drm.c b/src/gamma-drm.c
index 7ed223d..e912f85 100644
--- a/src/gamma-drm.c
+++ b/src/gamma-drm.c
@@ -48,11 +48,13 @@ struct gamma_state {
static int
drm_init(struct gamma_state **state)
{
+ struct gamma_state *s;
+
/* Initialize state. */
- *state = malloc(sizeof(struct gamma_state));
+ *state = malloc(sizeof(**state));
if (*state == NULL) return -1;
- struct gamma_state *s = *state;
+ s = *state;
s->card_num = 0;
s->crtc_num = -1;
s->fd = -1;
@@ -68,6 +70,8 @@ drm_start(struct gamma_state *state, enum program_mode mode)
/* Acquire access to a graphics card. */
long maxlen = strlen(DRM_DIR_NAME) + strlen(DRM_DEV_NAME) + 10;
char pathname[maxlen];
+ int crtc_count;
+ struct drm_crtc_state *crtcs;
sprintf(pathname, DRM_DEV_NAME, DRM_DIR_NAME, state->card_num);
@@ -91,7 +95,7 @@ drm_start(struct gamma_state *state, enum program_mode mode)
}
/* Create entries for selected CRTCs. */
- int crtc_count = state->res->count_crtcs;
+ crtc_count = state->res->count_crtcs;
if (state->crtc_num >= 0) {
if (state->crtc_num >= crtc_count) {
fprintf(stderr, _("CRTC %d does not exist. "),
@@ -133,10 +137,11 @@ drm_start(struct gamma_state *state, enum program_mode mode)
}
/* Load CRTC information and gamma ramps. */
- struct drm_crtc_state *crtcs = state->crtcs;
+ crtcs = state->crtcs;
for (; crtcs->crtc_num >= 0; crtcs++) {
+ drmModeCrtc *crtc_info;
crtcs->crtc_id = state->res->crtcs[crtcs->crtc_num];
- drmModeCrtc* crtc_info = drmModeGetCrtc(state->fd, crtcs->crtc_id);
+ crtc_info = drmModeGetCrtc(state->fd, crtcs->crtc_id);
if (crtc_info == NULL) {
fprintf(stderr, _("CRTC %i lost, skipping\n"), crtcs->crtc_num);
continue;
@@ -259,6 +264,8 @@ drm_set_temperature(
uint16_t *r_gamma = NULL;
uint16_t *g_gamma = NULL;
uint16_t *b_gamma = NULL;
+ uint16_t value;
+ uint32_t i, ramp_size;
for (; crtcs->crtc_num >= 0; crtcs++) {
if (crtcs->gamma_size <= 1)
@@ -281,9 +288,9 @@ drm_set_temperature(
}
/* Initialize gamma ramps to pure state */
- uint32_t ramp_size = crtcs->gamma_size;
- for (uint32_t i = 0; i < ramp_size; i++) {
- uint16_t value = (double)i/ramp_size * (UINT16_MAX+1);
+ ramp_size = crtcs->gamma_size;
+ for (i = 0; i < ramp_size; i++) {
+ value = (uint16_t)((double)i/ramp_size * (UINT16_MAX+1));
r_gamma[i] = value;
g_gamma[i] = value;
b_gamma[i] = value;