return (int64_t)*((int64_t *)&val);
}
+static float mode_vrefresh(drmModeModeInfo *mode)
+{
+ return mode->clock * 1000.00
+ / (mode->htotal * mode->vtotal);
+}
+
#define bit_name_fn(res) \
const char * res##_str(int type) { \
unsigned int i; \
static void dump_mode(drmModeModeInfo *mode)
{
- printf(" %s %d %d %d %d %d %d %d %d %d %d",
+ printf(" %s %.2f %d %d %d %d %d %d %d %d %d",
mode->name,
- mode->vrefresh,
+ mode_vrefresh(mode),
mode->hdisplay,
mode->hsync_start,
mode->hsync_end,
drmModeConnector *connector;
drmModeModeInfo *mode;
int i;
- float mode_vrefresh;
connector = get_connector_by_id(dev, con_id);
if (!connector || !connector->count_modes)
for (i = 0; i < connector->count_modes; i++) {
mode = &connector->modes[i];
if (!strcmp(mode->name, mode_str)) {
- /* If the vertical refresh frequency is not specified then return the
- * first mode that match with the name. Else, return the mode that match
- * the name and the specified vertical refresh frequency.
+ /* If the vertical refresh frequency is not specified
+ * then return the first mode that match with the name.
+ * Else, return the mode that match the name and
+ * the specified vertical refresh frequency.
*/
- mode_vrefresh = mode->clock * 1000.00
- / (mode->htotal * mode->vtotal);
if (vrefresh == 0)
return mode;
- else if (fabs(mode_vrefresh - vrefresh) < 0.005)
+ else if (fabs(mode_vrefresh(mode) - vrefresh) < 0.005)
return mode;
}
}
mode = connector_find_mode(dev, pipe->con_ids[i],
pipe->mode_str, pipe->vrefresh);
if (mode == NULL) {
- fprintf(stderr,
+ if (pipe->vrefresh)
+ fprintf(stderr,
+ "failed to find mode "
+ "\"%s-%.2fHz\" for connector %s\n",
+ pipe->mode_str, pipe->vrefresh, pipe->cons[i]);
+ else
+ fprintf(stderr,
"failed to find mode \"%s\" for connector %s\n",
pipe->mode_str, pipe->cons[i]);
return -EINVAL;
continue;
printf("setting mode %s-%.2fHz on connectors ",
- pipe->mode_str, pipe->vrefresh);
+ pipe->mode->name, mode_vrefresh(pipe->mode));
for (j = 0; j < pipe->num_cons; ++j) {
printf("%s, ", pipe->cons[j]);
add_property(dev, pipe->con_ids[j], "CRTC_ID", pipe->crtc->crtc->crtc_id);
continue;
printf("setting mode %s-%.2fHz@%s on connectors ",
- pipe->mode_str, pipe->vrefresh, pipe->format_str);
+ pipe->mode->name, mode_vrefresh(pipe->mode),
+ pipe->format_str);
for (j = 0; j < pipe->num_cons; ++j)
printf("%s, ", pipe->cons[j]);
printf("crtc %d\n", pipe->crtc->crtc->crtc_id);