Commit d50ba256 authored by Dave Airlie's avatar Dave Airlie

drm/kms: start adding command line interface using fb.

[note this requires an fb patch posted to linux-fbdev-devel already]

This uses the normal video= command line option to control the kms
output setup at boot time. It is used to override the autodetection
done by kms.

video= normally takes a framebuffer as the first parameter, in kms
it will take a connector name, DVI-I-1, or LVDS-1 etc. If no output
connector is specified the mode string will apply to all connectors.

The mode specification used will match down the probed modes, and if
no mode is found it will add a CVT mode that matches.

video=1024x768 - all connectors match a 1024x768 mode or add a CVT on
video=VGA-1:1024x768, VGA-1 connector gets mode only.

The same strings as used in current fb modedb.c are used, except I've
added three more letters, e, D, d, e = enable, D = enable Digital,
d = disable, which allow a connector to be forced into a certain state.
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent f8033035
...@@ -482,6 +482,7 @@ void drm_connector_cleanup(struct drm_connector *connector) ...@@ -482,6 +482,7 @@ void drm_connector_cleanup(struct drm_connector *connector)
list_for_each_entry_safe(mode, t, &connector->user_modes, head) list_for_each_entry_safe(mode, t, &connector->user_modes, head)
drm_mode_remove(connector, mode); drm_mode_remove(connector, mode);
kfree(connector->fb_helper_private);
mutex_lock(&dev->mode_config.mutex); mutex_lock(&dev->mode_config.mutex);
drm_mode_object_put(dev, &connector->base); drm_mode_object_put(dev, &connector->base);
list_del(&connector->head); list_del(&connector->head);
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "drmP.h" #include "drmP.h"
#include "drm_crtc.h" #include "drm_crtc.h"
#include "drm_crtc_helper.h" #include "drm_crtc_helper.h"
#include "drm_fb_helper.h"
static void drm_mode_validate_flag(struct drm_connector *connector, static void drm_mode_validate_flag(struct drm_connector *connector,
int flags) int flags)
...@@ -90,6 +91,14 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector, ...@@ -90,6 +91,14 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
list_for_each_entry_safe(mode, t, &connector->modes, head) list_for_each_entry_safe(mode, t, &connector->modes, head)
mode->status = MODE_UNVERIFIED; mode->status = MODE_UNVERIFIED;
if (connector->force) {
if (connector->force == DRM_FORCE_ON)
connector->status = connector_status_connected;
else
connector->status = connector_status_disconnected;
if (connector->funcs->force)
connector->funcs->force(connector);
} else
connector->status = connector->funcs->detect(connector); connector->status = connector->funcs->detect(connector);
if (connector->status == connector_status_disconnected) { if (connector->status == connector_status_disconnected) {
...@@ -267,6 +276,56 @@ static struct drm_display_mode *drm_has_preferred_mode(struct drm_connector *con ...@@ -267,6 +276,56 @@ static struct drm_display_mode *drm_has_preferred_mode(struct drm_connector *con
return NULL; return NULL;
} }
static bool drm_has_cmdline_mode(struct drm_connector *connector)
{
struct drm_fb_helper_connector *fb_help_conn = connector->fb_helper_private;
struct drm_fb_helper_cmdline_mode *cmdline_mode = &fb_help_conn->cmdline_mode;
return cmdline_mode->specified;
}
static struct drm_display_mode *drm_pick_cmdline_mode(struct drm_connector *connector, int width, int height)
{
struct drm_fb_helper_connector *fb_help_conn = connector->fb_helper_private;
struct drm_fb_helper_cmdline_mode *cmdline_mode = &fb_help_conn->cmdline_mode;
struct drm_display_mode *mode = NULL;
if (cmdline_mode->specified == false)
return mode;
/* attempt to find a matching mode in the list of modes
* we have gotten so far, if not add a CVT mode that conforms
*/
if (cmdline_mode->rb || cmdline_mode->margins)
goto create_mode;
list_for_each_entry(mode, &connector->modes, head) {
/* check width/height */
if (mode->hdisplay != cmdline_mode->xres ||
mode->vdisplay != cmdline_mode->yres)
continue;
if (cmdline_mode->refresh_specified) {
if (mode->vrefresh != cmdline_mode->refresh)
continue;
}
if (cmdline_mode->interlace) {
if (!(mode->flags & DRM_MODE_FLAG_INTERLACE))
continue;
}
return mode;
}
create_mode:
mode = drm_cvt_mode(connector->dev, cmdline_mode->xres,
cmdline_mode->yres,
cmdline_mode->refresh_specified ? cmdline_mode->refresh : 60,
cmdline_mode->rb, cmdline_mode->interlace,
cmdline_mode->margins);
list_add(&mode->head, &connector->modes);
return mode;
}
static bool drm_connector_enabled(struct drm_connector *connector, bool strict) static bool drm_connector_enabled(struct drm_connector *connector, bool strict)
{ {
bool enable; bool enable;
...@@ -317,10 +376,16 @@ static bool drm_target_preferred(struct drm_device *dev, ...@@ -317,10 +376,16 @@ static bool drm_target_preferred(struct drm_device *dev,
continue; continue;
} }
DRM_DEBUG_KMS("looking for preferred mode on connector %d\n", DRM_DEBUG_KMS("looking for cmdline mode on connector %d\n",
connector->base.id); connector->base.id);
/* got for command line mode first */
modes[i] = drm_pick_cmdline_mode(connector, width, height);
if (!modes[i]) {
DRM_DEBUG_KMS("looking for preferred mode on connector %d\n",
connector->base.id);
modes[i] = drm_has_preferred_mode(connector, width, height); modes[i] = drm_has_preferred_mode(connector, width, height);
}
/* No preferred modes, pick one off the list */ /* No preferred modes, pick one off the list */
if (!modes[i] && !list_empty(&connector->modes)) { if (!modes[i] && !list_empty(&connector->modes)) {
list_for_each_entry(modes[i], &connector->modes, head) list_for_each_entry(modes[i], &connector->modes, head)
...@@ -369,6 +434,8 @@ static int drm_pick_crtcs(struct drm_device *dev, ...@@ -369,6 +434,8 @@ static int drm_pick_crtcs(struct drm_device *dev,
my_score = 1; my_score = 1;
if (connector->status == connector_status_connected) if (connector->status == connector_status_connected)
my_score++; my_score++;
if (drm_has_cmdline_mode(connector))
my_score++;
if (drm_has_preferred_mode(connector, width, height)) if (drm_has_preferred_mode(connector, width, height))
my_score++; my_score++;
...@@ -943,6 +1010,8 @@ bool drm_helper_initial_config(struct drm_device *dev) ...@@ -943,6 +1010,8 @@ bool drm_helper_initial_config(struct drm_device *dev)
{ {
int count = 0; int count = 0;
drm_fb_helper_parse_command_line(dev);
count = drm_helper_probe_connector_modes(dev, count = drm_helper_probe_connector_modes(dev,
dev->mode_config.max_width, dev->mode_config.max_width,
dev->mode_config.max_height); dev->mode_config.max_height);
...@@ -950,7 +1019,7 @@ bool drm_helper_initial_config(struct drm_device *dev) ...@@ -950,7 +1019,7 @@ bool drm_helper_initial_config(struct drm_device *dev)
/* /*
* we shouldn't end up with no modes here. * we shouldn't end up with no modes here.
*/ */
WARN(!count, "Connected connector with 0 modes\n"); WARN(!count, "No connectors reported connected with modes\n");
drm_setup_crtcs(dev); drm_setup_crtcs(dev);
......
...@@ -560,7 +560,8 @@ struct drm_display_mode *drm_mode_std(struct drm_device *dev, ...@@ -560,7 +560,8 @@ struct drm_display_mode *drm_mode_std(struct drm_device *dev,
vsize = (hsize * 9) / 16; vsize = (hsize * 9) / 16;
/* HDTV hack */ /* HDTV hack */
if (hsize == 1360 && vsize == 765 && vrefresh_rate == 60) { if (hsize == 1360 && vsize == 765 && vrefresh_rate == 60) {
mode = drm_cvt_mode(dev, hsize, vsize, vrefresh_rate, 0, 0); mode = drm_cvt_mode(dev, hsize, vsize, vrefresh_rate, 0, 0,
false);
mode->hdisplay = 1366; mode->hdisplay = 1366;
mode->vsync_start = mode->vsync_start - 1; mode->vsync_start = mode->vsync_start - 1;
mode->vsync_end = mode->vsync_end - 1; mode->vsync_end = mode->vsync_end - 1;
...@@ -579,7 +580,8 @@ struct drm_display_mode *drm_mode_std(struct drm_device *dev, ...@@ -579,7 +580,8 @@ struct drm_display_mode *drm_mode_std(struct drm_device *dev,
mode = drm_gtf_mode(dev, hsize, vsize, vrefresh_rate, 0, 0); mode = drm_gtf_mode(dev, hsize, vsize, vrefresh_rate, 0, 0);
break; break;
case LEVEL_CVT: case LEVEL_CVT:
mode = drm_cvt_mode(dev, hsize, vsize, vrefresh_rate, 0, 0); mode = drm_cvt_mode(dev, hsize, vsize, vrefresh_rate, 0, 0,
false);
break; break;
} }
return mode; return mode;
......
...@@ -40,6 +40,196 @@ MODULE_LICENSE("GPL and additional rights"); ...@@ -40,6 +40,196 @@ MODULE_LICENSE("GPL and additional rights");
static LIST_HEAD(kernel_fb_helper_list); static LIST_HEAD(kernel_fb_helper_list);
int drm_fb_helper_add_connector(struct drm_connector *connector)
{
connector->fb_helper_private = kzalloc(sizeof(struct drm_fb_helper_connector), GFP_KERNEL);
if (!connector->fb_helper_private)
return -ENOMEM;
return 0;
}
EXPORT_SYMBOL(drm_fb_helper_add_connector);
static int my_atoi(const char *name)
{
int val = 0;
for (;; name++) {
switch (*name) {
case '0' ... '9':
val = 10*val+(*name-'0');
break;
default:
return val;
}
}
}
/**
* drm_fb_helper_connector_parse_command_line - parse command line for connector
* @connector - connector to parse line for
* @mode_option - per connector mode option
*
* This parses the connector specific then generic command lines for
* modes and options to configure the connector.
*
* This uses the same parameters as the fb modedb.c, except for extra
* <xres>x<yres>[M][R][-<bpp>][@<refresh>][i][m][eDd]
*
* enable/enable Digital/disable bit at the end
*/
static bool drm_fb_helper_connector_parse_command_line(struct drm_connector *connector,
const char *mode_option)
{
const char *name;
unsigned int namelen;
int res_specified = 0, bpp_specified = 0, refresh_specified = 0;
unsigned int xres = 0, yres = 0, bpp = 32, refresh = 0;
int yres_specified = 0, cvt = 0, rb = 0, interlace = 0, margins = 0;
int i;
enum drm_connector_force force = DRM_FORCE_UNSPECIFIED;
struct drm_fb_helper_connector *fb_help_conn = connector->fb_helper_private;
struct drm_fb_helper_cmdline_mode *cmdline_mode = &fb_help_conn->cmdline_mode;
if (!mode_option)
mode_option = fb_mode_option;
if (!mode_option) {
cmdline_mode->specified = false;
return false;
}
name = mode_option;
namelen = strlen(name);
for (i = namelen-1; i >= 0; i--) {
switch (name[i]) {
case '@':
namelen = i;
if (!refresh_specified && !bpp_specified &&
!yres_specified) {
refresh = my_atoi(&name[i+1]);
refresh_specified = 1;
if (cvt || rb)
cvt = 0;
} else
goto done;
break;
case '-':
namelen = i;
if (!bpp_specified && !yres_specified) {
bpp = my_atoi(&name[i+1]);
bpp_specified = 1;
if (cvt || rb)
cvt = 0;
} else
goto done;
break;
case 'x':
if (!yres_specified) {
yres = my_atoi(&name[i+1]);
yres_specified = 1;
} else
goto done;
case '0' ... '9':
break;
case 'M':
if (!yres_specified)
cvt = 1;
break;
case 'R':
if (!cvt)
rb = 1;
break;
case 'm':
if (!cvt)
margins = 1;
break;
case 'i':
if (!cvt)
interlace = 1;
break;
case 'e':
force = DRM_FORCE_ON;
break;
case 'D':
if ((connector->connector_type != DRM_MODE_CONNECTOR_DVII) ||
(connector->connector_type != DRM_MODE_CONNECTOR_HDMIB))
force = DRM_FORCE_ON;
else
force = DRM_FORCE_ON_DIGITAL;
break;
case 'd':
force = DRM_FORCE_OFF;
break;
default:
goto done;
}
}
if (i < 0 && yres_specified) {
xres = my_atoi(name);
res_specified = 1;
}
done:
DRM_DEBUG_KMS("cmdline mode for connector %s %dx%d@%dHz%s%s%s\n",
drm_get_connector_name(connector), xres, yres,
(refresh) ? refresh : 60, (rb) ? " reduced blanking" :
"", (margins) ? " with margins" : "", (interlace) ?
" interlaced" : "");
if (force) {
const char *s;
switch (force) {
case DRM_FORCE_OFF: s = "OFF"; break;
case DRM_FORCE_ON_DIGITAL: s = "ON - dig"; break;
default:
case DRM_FORCE_ON: s = "ON"; break;
}
DRM_INFO("forcing %s connector %s\n",
drm_get_connector_name(connector), s);
connector->force = force;
}
if (res_specified) {
cmdline_mode->specified = true;
cmdline_mode->xres = xres;
cmdline_mode->yres = yres;
}
if (refresh_specified) {
cmdline_mode->refresh_specified = true;
cmdline_mode->refresh = refresh;
}
if (bpp_specified) {
cmdline_mode->bpp_specified = true;
cmdline_mode->bpp = bpp;
}
cmdline_mode->rb = rb ? true : false;
cmdline_mode->cvt = cvt ? true : false;
cmdline_mode->interlace = interlace ? true : false;
return true;
}
int drm_fb_helper_parse_command_line(struct drm_device *dev)
{
struct drm_connector *connector;
list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
char *option = NULL;
/* do something on return - turn off connector maybe */
if (fb_get_options(drm_get_connector_name(connector), &option))
continue;
drm_fb_helper_connector_parse_command_line(connector, option);
}
return 0;
}
bool drm_fb_helper_force_kernel_mode(void) bool drm_fb_helper_force_kernel_mode(void)
{ {
int i = 0; int i = 0;
...@@ -484,6 +674,8 @@ int drm_fb_helper_single_fb_probe(struct drm_device *dev, ...@@ -484,6 +674,8 @@ int drm_fb_helper_single_fb_probe(struct drm_device *dev,
uint32_t fb_height, uint32_t fb_height,
uint32_t surface_width, uint32_t surface_width,
uint32_t surface_height, uint32_t surface_height,
uint32_t surface_depth,
uint32_t surface_bpp,
struct drm_framebuffer **fb_ptr)) struct drm_framebuffer **fb_ptr))
{ {
struct drm_crtc *crtc; struct drm_crtc *crtc;
...@@ -497,8 +689,37 @@ int drm_fb_helper_single_fb_probe(struct drm_device *dev, ...@@ -497,8 +689,37 @@ int drm_fb_helper_single_fb_probe(struct drm_device *dev,
struct drm_framebuffer *fb; struct drm_framebuffer *fb;
struct drm_mode_set *modeset = NULL; struct drm_mode_set *modeset = NULL;
struct drm_fb_helper *fb_helper; struct drm_fb_helper *fb_helper;
uint32_t surface_depth = 24, surface_bpp = 32;
/* first up get a count of crtcs now in use and new min/maxes width/heights */ /* first up get a count of crtcs now in use and new min/maxes width/heights */
list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
struct drm_fb_helper_connector *fb_help_conn = connector->fb_helper_private;
struct drm_fb_helper_cmdline_mode *cmdline_mode = &fb_help_conn->cmdline_mode;
if (cmdline_mode->bpp_specified) {
switch (cmdline_mode->bpp) {
case 8:
surface_depth = surface_bpp = 8;
break;
case 15:
surface_depth = 15;
surface_bpp = 16;
break;
case 16:
surface_depth = surface_bpp = 16;
break;
case 24:
surface_depth = surface_bpp = 24;
break;
case 32:
surface_depth = 24;
surface_bpp = 32;
break;
}
break;
}
}
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
if (drm_helper_crtc_in_use(crtc)) { if (drm_helper_crtc_in_use(crtc)) {
if (crtc->desired_mode) { if (crtc->desired_mode) {
...@@ -527,7 +748,8 @@ int drm_fb_helper_single_fb_probe(struct drm_device *dev, ...@@ -527,7 +748,8 @@ int drm_fb_helper_single_fb_probe(struct drm_device *dev,
/* do we have an fb already? */ /* do we have an fb already? */
if (list_empty(&dev->mode_config.fb_kernel_list)) { if (list_empty(&dev->mode_config.fb_kernel_list)) {
ret = (*fb_create)(dev, fb_width, fb_height, surface_width, ret = (*fb_create)(dev, fb_width, fb_height, surface_width,
surface_height, &fb); surface_height, surface_depth, surface_bpp,
&fb);
if (ret) if (ret)
return -EINVAL; return -EINVAL;
new_fb = 1; new_fb = 1;
......
...@@ -88,7 +88,7 @@ EXPORT_SYMBOL(drm_mode_debug_printmodeline); ...@@ -88,7 +88,7 @@ EXPORT_SYMBOL(drm_mode_debug_printmodeline);
#define HV_FACTOR 1000 #define HV_FACTOR 1000
struct drm_display_mode *drm_cvt_mode(struct drm_device *dev, int hdisplay, struct drm_display_mode *drm_cvt_mode(struct drm_device *dev, int hdisplay,
int vdisplay, int vrefresh, int vdisplay, int vrefresh,
bool reduced, bool interlaced) bool reduced, bool interlaced, bool margins)
{ {
/* 1) top/bottom margin size (% of height) - default: 1.8, */ /* 1) top/bottom margin size (% of height) - default: 1.8, */
#define CVT_MARGIN_PERCENTAGE 18 #define CVT_MARGIN_PERCENTAGE 18
...@@ -101,7 +101,6 @@ struct drm_display_mode *drm_cvt_mode(struct drm_device *dev, int hdisplay, ...@@ -101,7 +101,6 @@ struct drm_display_mode *drm_cvt_mode(struct drm_device *dev, int hdisplay,
/* Pixel Clock step (kHz) */ /* Pixel Clock step (kHz) */
#define CVT_CLOCK_STEP 250 #define CVT_CLOCK_STEP 250
struct drm_display_mode *drm_mode; struct drm_display_mode *drm_mode;
bool margins = false;
unsigned int vfieldrate, hperiod; unsigned int vfieldrate, hperiod;
int hdisplay_rnd, hmargin, vdisplay_rnd, vmargin, vsync; int hdisplay_rnd, hmargin, vdisplay_rnd, vmargin, vsync;
int interlace; int interlace;
......
...@@ -110,6 +110,7 @@ EXPORT_SYMBOL(intelfb_resize); ...@@ -110,6 +110,7 @@ EXPORT_SYMBOL(intelfb_resize);
static int intelfb_create(struct drm_device *dev, uint32_t fb_width, static int intelfb_create(struct drm_device *dev, uint32_t fb_width,
uint32_t fb_height, uint32_t surface_width, uint32_t fb_height, uint32_t surface_width,
uint32_t surface_height, uint32_t surface_height,
uint32_t surface_depth, uint32_t surface_bpp,
struct drm_framebuffer **fb_p) struct drm_framebuffer **fb_p)
{ {
struct fb_info *info; struct fb_info *info;
...@@ -125,9 +126,9 @@ static int intelfb_create(struct drm_device *dev, uint32_t fb_width, ...@@ -125,9 +126,9 @@ static int intelfb_create(struct drm_device *dev, uint32_t fb_width,
mode_cmd.width = surface_width; mode_cmd.width = surface_width;
mode_cmd.height = surface_height; mode_cmd.height = surface_height;
mode_cmd.bpp = 32; mode_cmd.bpp = surface_bpp;
mode_cmd.pitch = ALIGN(mode_cmd.width * ((mode_cmd.bpp + 1) / 8), 64); mode_cmd.pitch = ALIGN(mode_cmd.width * ((mode_cmd.bpp + 1) / 8), 64);
mode_cmd.depth = 24; mode_cmd.depth = surface_depth;
size = mode_cmd.pitch * mode_cmd.height; size = mode_cmd.pitch * mode_cmd.height;
size = ALIGN(size, PAGE_SIZE); size = ALIGN(size, PAGE_SIZE);
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "drmP.h" #include "drmP.h"
#include "drm_edid.h" #include "drm_edid.h"
#include "drm_crtc_helper.h" #include "drm_crtc_helper.h"
#include "drm_fb_helper.h"
#include "radeon_drm.h" #include "radeon_drm.h"
#include "radeon.h" #include "radeon.h"
#include "atom.h" #include "atom.h"
...@@ -245,7 +246,7 @@ static void radeon_add_common_modes(struct drm_encoder *encoder, struct drm_conn ...@@ -245,7 +246,7 @@ static void radeon_add_common_modes(struct drm_encoder *encoder, struct drm_conn
if (common_modes[i].w < 320 || common_modes[i].h < 200) if (common_modes[i].w < 320 || common_modes[i].h < 200)
continue; continue;
mode = drm_cvt_mode(dev, common_modes[i].w, common_modes[i].h, 60, false, false); mode = drm_cvt_mode(dev, common_modes[i].w, common_modes[i].h, 60, false, false, false);
drm_mode_probed_add(connector, mode); drm_mode_probed_add(connector, mode);
} }
} }
...@@ -559,7 +560,7 @@ static int radeon_tv_get_modes(struct drm_connector *connector) ...@@ -559,7 +560,7 @@ static int radeon_tv_get_modes(struct drm_connector *connector)
radeon_add_common_modes(encoder, connector); radeon_add_common_modes(encoder, connector);
else { else {
/* only 800x600 is supported right now on pre-avivo chips */ /* only 800x600 is supported right now on pre-avivo chips */
tv_mode = drm_cvt_mode(dev, 800, 600, 60, false, false); tv_mode = drm_cvt_mode(dev, 800, 600, 60, false, false, false);
tv_mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; tv_mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
drm_mode_probed_add(connector, tv_mode); drm_mode_probed_add(connector, tv_mode);
} }
...@@ -743,6 +744,15 @@ struct drm_encoder *radeon_dvi_encoder(struct drm_connector *connector) ...@@ -743,6 +744,15 @@ struct drm_encoder *radeon_dvi_encoder(struct drm_connector *connector)
return NULL; return NULL;
} }
static void radeon_dvi_force(struct drm_connector *connector)
{
struct radeon_connector *radeon_connector = to_radeon_connector(connector);
if (connector->force == DRM_FORCE_ON)
radeon_connector->use_digital = false;
if (connector->force == DRM_FORCE_ON_DIGITAL)
radeon_connector->use_digital = true;
}
struct drm_connector_helper_funcs radeon_dvi_connector_helper_funcs = { struct drm_connector_helper_funcs radeon_dvi_connector_helper_funcs = {
.get_modes = radeon_dvi_get_modes, .get_modes = radeon_dvi_get_modes,
.mode_valid = radeon_vga_mode_valid, .mode_valid = radeon_vga_mode_valid,
...@@ -755,6 +765,7 @@ struct drm_connector_funcs radeon_dvi_connector_funcs = { ...@@ -755,6 +765,7 @@ struct drm_connector_funcs radeon_dvi_connector_funcs = {
.fill_modes = drm_helper_probe_single_connector_modes, .fill_modes = drm_helper_probe_single_connector_modes,
.set_property = radeon_connector_set_property, .set_property = radeon_connector_set_property,
.destroy = radeon_connector_destroy, .destroy = radeon_connector_destroy,
.force = radeon_dvi_force,
}; };
void void
...@@ -771,6 +782,7 @@ radeon_add_atom_connector(struct drm_device *dev, ...@@ -771,6 +782,7 @@ radeon_add_atom_connector(struct drm_device *dev,
struct radeon_connector *radeon_connector; struct radeon_connector *radeon_connector;
struct radeon_connector_atom_dig *radeon_dig_connector; struct radeon_connector_atom_dig *radeon_dig_connector;
uint32_t subpixel_order = SubPixelNone; uint32_t subpixel_order = SubPixelNone;
int ret;
/* fixme - tv/cv/din */ /* fixme - tv/cv/din */
if (connector_type == DRM_MODE_CONNECTOR_Unknown) if (connector_type == DRM_MODE_CONNECTOR_Unknown)
...@@ -914,6 +926,10 @@ radeon_add_atom_connector(struct drm_device *dev, ...@@ -914,6 +926,10 @@ radeon_add_atom_connector(struct drm_device *dev,
break; break;
} }
ret = drm_fb_helper_add_connector(connector);
if (ret)
goto failed;
connector->display_info.subpixel_order = subpixel_order; connector->display_info.subpixel_order = subpixel_order;
drm_sysfs_connector_add(connector); drm_sysfs_connector_add(connector);
return; return;
...@@ -936,6 +952,7 @@ radeon_add_legacy_connector(struct drm_device *dev, ...@@ -936,6 +952,7 @@ radeon_add_legacy_connector(struct drm_device *dev,
struct drm_connector *connector; struct drm_connector *connector;
struct radeon_connector *radeon_connector; struct radeon_connector *radeon_connector;
uint32_t subpixel_order = SubPixelNone; uint32_t subpixel_order = SubPixelNone;
int ret;
/* fixme - tv/cv/din */ /* fixme - tv/cv/din */
if (connector_type == DRM_MODE_CONNECTOR_Unknown) if (connector_type == DRM_MODE_CONNECTOR_Unknown)
...@@ -1027,6 +1044,10 @@ radeon_add_legacy_connector(struct drm_device *dev, ...@@ -1027,6 +1044,10 @@ radeon_add_legacy_connector(struct drm_device *dev,
break; break;
} }
ret = drm_fb_helper_add_connector(connector);
if (ret)
goto failed;
connector->display_info.subpixel_order = subpixel_order; connector->display_info.subpixel_order = subpixel_order;
drm_sysfs_connector_add(connector); drm_sysfs_connector_add(connector);
return; return;
......
...@@ -128,6 +128,7 @@ static struct drm_fb_helper_funcs radeon_fb_helper_funcs = { ...@@ -128,6 +128,7 @@ static struct drm_fb_helper_funcs radeon_fb_helper_funcs = {
int radeonfb_create(struct drm_device *dev, int radeonfb_create(struct drm_device *dev,
uint32_t fb_width, uint32_t fb_height, uint32_t fb_width, uint32_t fb_height,
uint32_t surface_width, uint32_t surface_height, uint32_t surface_width, uint32_t surface_height,
uint32_t surface_depth, uint32_t surface_bpp,
struct drm_framebuffer **fb_p) struct drm_framebuffer **fb_p)
{ {
struct radeon_device *rdev = dev->dev_private; struct radeon_device *rdev = dev->dev_private;
...@@ -148,10 +149,10 @@ int radeonfb_create(struct drm_device *dev, ...@@ -148,10 +149,10 @@ int radeonfb_create(struct drm_device *dev,
mode_cmd.width = surface_width; mode_cmd.width = surface_width;
mode_cmd.height = surface_height; mode_cmd.height = surface_height;
mode_cmd.bpp = 32; mode_cmd.bpp = surface_bpp;
/* need to align pitch with crtc limits */ /* need to align pitch with crtc limits */
mode_cmd.pitch = radeon_align_pitch(rdev, mode_cmd.width, mode_cmd.bpp, fb_tiled) * ((mode_cmd.bpp + 1) / 8); mode_cmd.pitch = radeon_align_pitch(rdev, mode_cmd.width, mode_cmd.bpp, fb_tiled) * ((mode_cmd.bpp + 1) / 8);
mode_cmd.depth = 24; mode_cmd.depth = surface_depth;
size = mode_cmd.pitch * mode_cmd.height; size = mode_cmd.pitch * mode_cmd.height;
aligned_size = ALIGN(size, PAGE_SIZE); aligned_size = ALIGN(size, PAGE_SIZE);
...@@ -290,13 +291,26 @@ int radeonfb_create(struct drm_device *dev, ...@@ -290,13 +291,26 @@ int radeonfb_create(struct drm_device *dev,
return ret; return ret;
} }
static char *mode_option;
int radeon_parse_options(char *options)
{
char *this_opt;
if (!options || !*options)
return 0;
while ((this_opt = strsep(&options, ",")) != NULL) {
if (!*this_opt)
continue;
mode_option = this_opt;
}
return 0;
}
int radeonfb_probe(struct drm_device *dev) int radeonfb_probe(struct drm_device *dev)
{ {
int ret; return drm_fb_helper_single_fb_probe(dev, &radeonfb_create);
ret = drm_fb_helper_single_fb_probe(dev, &radeonfb_create);
return ret;
} }
EXPORT_SYMBOL(radeonfb_probe);
int radeonfb_remove(struct drm_device *dev, struct drm_framebuffer *fb) int radeonfb_remove(struct drm_device *dev, struct drm_framebuffer *fb)
{ {
......
...@@ -387,6 +387,7 @@ struct drm_crtc { ...@@ -387,6 +387,7 @@ struct drm_crtc {
* @get_modes: get mode list for this connector * @get_modes: get mode list for this connector
* @set_property: property for this connector may need update * @set_property: property for this connector may need update
* @destroy: make object go away * @destroy: make object go away
* @force: notify the driver the connector is forced on
* *
* Each CRTC may have one or more connectors attached to it. The functions * Each CRTC may have one or more connectors attached to it. The functions
* below allow the core DRM code to control connectors, enumerate available modes, * below allow the core DRM code to control connectors, enumerate available modes,
...@@ -401,6 +402,7 @@ struct drm_connector_funcs { ...@@ -401,6 +402,7 @@ struct drm_connector_funcs {
int (*set_property)(struct drm_connector *connector, struct drm_property *property, int (*set_property)(struct drm_connector *connector, struct drm_property *property,
uint64_t val); uint64_t val);
void (*destroy)(struct drm_connector *connector); void (*destroy)(struct drm_connector *connector);
void (*force)(struct drm_connector *connector);
}; };
struct drm_encoder_funcs { struct drm_encoder_funcs {
...@@ -429,6 +431,13 @@ struct drm_encoder { ...@@ -429,6 +431,13 @@ struct drm_encoder {
void *helper_private; void *helper_private;
}; };
enum drm_connector_force {
DRM_FORCE_UNSPECIFIED,
DRM_FORCE_OFF,
DRM_FORCE_ON, /* force on analog part normally */
DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */
};
/** /**
* drm_connector - central DRM connector control structure * drm_connector - central DRM connector control structure
* @crtc: CRTC this connector is currently connected to, NULL if none * @crtc: CRTC this connector is currently connected to, NULL if none
...@@ -478,9 +487,12 @@ struct drm_connector { ...@@ -478,9 +487,12 @@ struct drm_connector {
void *helper_private; void *helper_private;
/* forced on connector */
enum drm_connector_force force;
uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER]; uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER];
uint32_t force_encoder_id; uint32_t force_encoder_id;
struct drm_encoder *encoder; /* currently active encoder */ struct drm_encoder *encoder; /* currently active encoder */
void *fb_helper_private;
}; };
/** /**
...@@ -746,7 +758,7 @@ extern int drm_mode_gamma_set_ioctl(struct drm_device *dev, ...@@ -746,7 +758,7 @@ extern int drm_mode_gamma_set_ioctl(struct drm_device *dev,
extern bool drm_detect_hdmi_monitor(struct edid *edid); extern bool drm_detect_hdmi_monitor(struct edid *edid);
extern struct drm_display_mode *drm_cvt_mode(struct drm_device *dev, extern struct drm_display_mode *drm_cvt_mode(struct drm_device *dev,
int hdisplay, int vdisplay, int vrefresh, int hdisplay, int vdisplay, int vrefresh,
bool reduced, bool interlaced); bool reduced, bool interlaced, bool margins);
extern struct drm_display_mode *drm_gtf_mode(struct drm_device *dev, extern struct drm_display_mode *drm_gtf_mode(struct drm_device *dev,
int hdisplay, int vdisplay, int vrefresh, int hdisplay, int vdisplay, int vrefresh,
bool interlaced, int margins); bool interlaced, int margins);
......
...@@ -35,11 +35,30 @@ struct drm_fb_helper_crtc { ...@@ -35,11 +35,30 @@ struct drm_fb_helper_crtc {
struct drm_mode_set mode_set; struct drm_mode_set mode_set;
}; };
struct drm_fb_helper_funcs { struct drm_fb_helper_funcs {
void (*gamma_set)(struct drm_crtc *crtc, u16 red, u16 green, void (*gamma_set)(struct drm_crtc *crtc, u16 red, u16 green,
u16 blue, int regno); u16 blue, int regno);
}; };
/* mode specified on the command line */
struct drm_fb_helper_cmdline_mode {
bool specified;
bool refresh_specified;
bool bpp_specified;
int xres, yres;
int bpp;
int refresh;
bool rb;
bool interlace;
bool cvt;
bool margins;
};
struct drm_fb_helper_connector {
struct drm_fb_helper_cmdline_mode cmdline_mode;
};
struct drm_fb_helper { struct drm_fb_helper {
struct drm_framebuffer *fb; struct drm_framebuffer *fb;
struct drm_device *dev; struct drm_device *dev;
...@@ -57,6 +76,8 @@ int drm_fb_helper_single_fb_probe(struct drm_device *dev, ...@@ -57,6 +76,8 @@ int drm_fb_helper_single_fb_probe(struct drm_device *dev,
uint32_t fb_height, uint32_t fb_height,
uint32_t surface_width, uint32_t surface_width,
uint32_t surface_height, uint32_t surface_height,
uint32_t surface_depth,
uint32_t surface_bpp,
struct drm_framebuffer **fb_ptr)); struct drm_framebuffer **fb_ptr));
int drm_fb_helper_init_crtc_count(struct drm_fb_helper *helper, int crtc_count, int drm_fb_helper_init_crtc_count(struct drm_fb_helper *helper, int crtc_count,
int max_conn); int max_conn);
...@@ -79,4 +100,7 @@ void drm_fb_helper_fill_var(struct fb_info *info, struct drm_framebuffer *fb, ...@@ -79,4 +100,7 @@ void drm_fb_helper_fill_var(struct fb_info *info, struct drm_framebuffer *fb,
uint32_t fb_width, uint32_t fb_height); uint32_t fb_width, uint32_t fb_height);
void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch); void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch);
int drm_fb_helper_add_connector(struct drm_connector *connector);
int drm_fb_helper_parse_command_line(struct drm_device *dev);
#endif #endif
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