Back to index

xserver-xorg-video-modesetting  0.3.0
Classes | Defines | Typedefs | Functions
drmmode_display.h File Reference
#include "xf86drmMode.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  dumb_bo
struct  drmmode_rec
struct  drmmode_crtc_private_rec
struct  drmmode_prop_rec
struct  drmmode_output_private_rec

Defines

#define DRM_CAP_DUMB_PREFERRED_DEPTH   3
#define DRM_CAP_DUMB_PREFER_SHADOW   4

Typedefs

typedef struct drmmode_recdrmmode_ptr
typedef struct
drmmode_crtc_private_rec
drmmode_crtc_private_ptr
typedef struct drmmode_prop_recdrmmode_prop_ptr
typedef struct
drmmode_output_private_rec
drmmode_output_private_ptr

Functions

Bool drmmode_pre_init (ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp)
void drmmode_adjust_frame (ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y, int flags)
Bool drmmode_set_desired_modes (ScrnInfoPtr pScrn, drmmode_ptr drmmode)
Bool drmmode_setup_colormap (ScreenPtr pScreen, ScrnInfoPtr pScrn)
void drmmode_uevent_init (ScrnInfoPtr scrn, drmmode_ptr drmmode)
void drmmode_uevent_fini (ScrnInfoPtr scrn, drmmode_ptr drmmode)
Bool drmmode_create_initial_bos (ScrnInfoPtr pScrn, drmmode_ptr drmmode)
void * drmmode_map_front_bo (drmmode_ptr drmmode)
Bool drmmode_map_cursor_bos (ScrnInfoPtr pScrn, drmmode_ptr drmmode)
void drmmode_free_bos (ScrnInfoPtr pScrn, drmmode_ptr drmmode)
void drmmode_get_default_bpp (ScrnInfoPtr pScrn, drmmode_ptr drmmmode, int *depth, int *bpp)

Class Documentation

struct dumb_bo

Definition at line 35 of file drmmode_display.h.

Class Members
uint32_t handle
int map_count
uint32_t pitch
void * ptr
uint32_t size
struct drmmode_rec

Definition at line 43 of file drmmode_display.h.

Collaboration diagram for drmmode_rec:
Class Members
int cpp
drmEventContext event_context
unsigned fb_id
int fd
struct dumb_bo * front_bo
drmModeFBPtr mode_fb
drmModeResPtr mode_res
ScrnInfoPtr scrn
Bool shadow_enable
void * shadow_fb
Bool sw_cursor
struct drmmode_crtc_private_rec

Definition at line 63 of file drmmode_display.h.

Collaboration diagram for drmmode_crtc_private_rec:
Class Members
struct dumb_bo * cursor_bo
drmmode_ptr drmmode
int hw_id
uint16_t lut_b
uint16_t lut_g
uint16_t lut_r
drmModeCrtcPtr mode_crtc
unsigned rotate_fb_id
struct drmmode_prop_rec

Definition at line 72 of file drmmode_display.h.

Class Members
Atom * atoms
drmModePropertyPtr mode_prop
int num_atoms
uint64_t value
struct drmmode_output_private_rec

Definition at line 80 of file drmmode_display.h.

Collaboration diagram for drmmode_output_private_rec:
Class Members
int dpms_enum_id
drmmode_ptr drmmode
drmModePropertyBlobPtr edid_blob
int enc_clone_mask
int enc_mask
drmModeEncoderPtr * mode_encoders
drmModeConnectorPtr mode_output
int num_props
int output_id
drmmode_prop_ptr props

Define Documentation

Definition at line 112 of file drmmode_display.h.

Definition at line 109 of file drmmode_display.h.


Typedef Documentation

typedef struct drmmode_rec * drmmode_ptr

Function Documentation

void drmmode_adjust_frame ( ScrnInfoPtr  pScrn,
drmmode_ptr  drmmode,
int  x,
int  y,
int  flags 
)

Definition at line 1071 of file drmmode_display.c.

{
       xf86CrtcConfigPtr    config = XF86_CRTC_CONFIG_PTR(pScrn);
       xf86OutputPtr  output = config->output[config->compat_output];
       xf86CrtcPtr   crtc = output->crtc;

       if (crtc && crtc->enabled) {
              drmmode_set_mode_major(crtc, &crtc->mode, crtc->rotation,
                                   x, y);
       }
}

Here is the call graph for this function:

Bool drmmode_create_initial_bos ( ScrnInfoPtr  pScrn,
drmmode_ptr  drmmode 
)

Definition at line 1283 of file drmmode_display.c.

{
       xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
       int width;
       int height;
       int bpp = pScrn->bitsPerPixel;
       int i;
       int cpp = (bpp + 7) / 8;

       width = pScrn->virtualX;
       height = pScrn->virtualY;

       drmmode->front_bo = dumb_bo_create(drmmode->fd, width, height, bpp);
       if (!drmmode->front_bo)
              return FALSE;
       pScrn->displayWidth = drmmode->front_bo->pitch / cpp;

       width = height = 64;
       bpp = 32;
       for (i = 0; i < xf86_config->num_crtc; i++) {
              xf86CrtcPtr crtc = xf86_config->crtc[i];
              drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
              drmmode_crtc->cursor_bo = dumb_bo_create(drmmode->fd, width, height, bpp);
       }
       return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void drmmode_free_bos ( ScrnInfoPtr  pScrn,
drmmode_ptr  drmmode 
)

Definition at line 1339 of file drmmode_display.c.

{
       xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
       int i;

       if (drmmode->fb_id) {
              drmModeRmFB(drmmode->fd, drmmode->fb_id);
              drmmode->fb_id = 0;
       }

       dumb_bo_destroy(drmmode->fd, drmmode->front_bo);
       drmmode->front_bo = NULL;

       for (i = 0; i < xf86_config->num_crtc; i++) {
              xf86CrtcPtr crtc = xf86_config->crtc[i];
              drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
              dumb_bo_destroy(drmmode->fd, drmmode_crtc->cursor_bo);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void drmmode_get_default_bpp ( ScrnInfoPtr  pScrn,
drmmode_ptr  drmmmode,
int *  depth,
int *  bpp 
)

Definition at line 1360 of file drmmode_display.c.

{
       drmModeResPtr mode_res;
       uint64_t value;
       struct dumb_bo *bo;
       uint32_t fb_id;
       int ret;

       /* 16 is fine */
       ret = drmGetCap(drmmode->fd, DRM_CAP_DUMB_PREFERRED_DEPTH, &value);
       if (!ret && (value == 16 || value == 8)) {
              *depth = value;
              *bpp = value;
              return;
       }

       *depth = 24;
       mode_res = drmModeGetResources(drmmode->fd);
       if (!mode_res)
              return;

       /*create a bo */
       bo = dumb_bo_create(drmmode->fd, mode_res->min_width, mode_res->min_height, 32);
       if (!bo) {
              *bpp = 24;
              goto out;
       }

       ret = drmModeAddFB(drmmode->fd, mode_res->min_width, mode_res->min_height,
                         24, 32, bo->pitch, bo->handle, &fb_id);

       if (ret) {
              *bpp = 24;
              dumb_bo_destroy(drmmode->fd, bo);
              goto out;
       }

       drmModeRmFB(drmmode->fd, fb_id);
       *bpp = 32;

       dumb_bo_destroy(drmmode->fd, bo);
out:   
       drmModeFreeResources(mode_res);
       return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Bool drmmode_map_cursor_bos ( ScrnInfoPtr  pScrn,
drmmode_ptr  drmmode 
)

Definition at line 1325 of file drmmode_display.c.

{
       xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
       int i, ret;
       for (i = 0; i < xf86_config->num_crtc; i++) {
              xf86CrtcPtr crtc = xf86_config->crtc[i];
              drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
              ret = dumb_bo_map(drmmode->fd, drmmode_crtc->cursor_bo);
              if (ret)
                     return FALSE;
       }
       return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void* drmmode_map_front_bo ( drmmode_ptr  drmmode)

Definition at line 1310 of file drmmode_display.c.

{
       int ret;

       if (drmmode->front_bo->ptr)
              return drmmode->front_bo->ptr;

       ret = dumb_bo_map(drmmode->fd, drmmode->front_bo);
       if (ret)
              return NULL;

       return drmmode->front_bo->ptr;
       
}

Here is the call graph for this function:

Here is the caller graph for this function:

Bool drmmode_pre_init ( ScrnInfoPtr  pScrn,
drmmode_ptr  drmmode,
int  cpp 
)

Definition at line 1034 of file drmmode_display.c.

{
       int i, num_dvi = 0, num_hdmi = 0;
       int ret;
       uint64_t value = 0;

       /* check for dumb capability */
       ret = drmGetCap(drmmode->fd, DRM_CAP_DUMB_BUFFER, &value);
       if (ret > 0 || value != 1) {
              xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "KMS doesn't support dumb interface\n");
              return FALSE;
       }

       xf86CrtcConfigInit(pScrn, &drmmode_xf86crtc_config_funcs);

       drmmode->scrn = pScrn;
       drmmode->cpp = cpp;
       drmmode->mode_res = drmModeGetResources(drmmode->fd);
       if (!drmmode->mode_res)
              return FALSE;

       xf86CrtcSetSizeRange(pScrn, 320, 200, drmmode->mode_res->max_width, drmmode->mode_res->max_height);
       for (i = 0; i < drmmode->mode_res->count_crtcs; i++)
              if (!xf86IsEntityShared(pScrn->entityList[0]) || pScrn->confScreen->device->screen == i)
                     drmmode_crtc_init(pScrn, drmmode, i);

       for (i = 0; i < drmmode->mode_res->count_connectors; i++)
              drmmode_output_init(pScrn, drmmode, i, &num_dvi, &num_hdmi);

       /* workout clones */
       drmmode_clones_init(pScrn, drmmode);

       xf86InitialConfiguration(pScrn, TRUE);

       return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Bool drmmode_set_desired_modes ( ScrnInfoPtr  pScrn,
drmmode_ptr  drmmode 
)

Definition at line 1083 of file drmmode_display.c.

{
       xf86CrtcConfigPtr   config = XF86_CRTC_CONFIG_PTR(pScrn);
       int c;

       for (c = 0; c < config->num_crtc; c++) {
              xf86CrtcPtr   crtc = config->crtc[c];
              drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
              xf86OutputPtr output = NULL;
              int           o;

              /* Skip disabled CRTCs */
              if (!crtc->enabled) {
                     drmModeSetCrtc(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
                                   0, 0, 0, NULL, 0, NULL);
                     continue;
              }

              if (config->output[config->compat_output]->crtc == crtc)
                     output = config->output[config->compat_output];
              else
              {
                     for (o = 0; o < config->num_output; o++)
                            if (config->output[o]->crtc == crtc)
                            {
                                   output = config->output[o];
                                   break;
                            }
              }
              /* paranoia */
              if (!output)
                     continue;

              /* Mark that we'll need to re-set the mode for sure */
              memset(&crtc->mode, 0, sizeof(crtc->mode));
              if (!crtc->desiredMode.CrtcHDisplay)
              {
                     DisplayModePtr  mode = xf86OutputFindClosestMode (output, pScrn->currentMode);

                     if (!mode)
                            return FALSE;
                     crtc->desiredMode = *mode;
                     crtc->desiredRotation = RR_Rotate_0;
                     crtc->desiredX = 0;
                     crtc->desiredY = 0;
              }

              if (!crtc->funcs->set_mode_major(crtc, &crtc->desiredMode, crtc->desiredRotation,
                                           crtc->desiredX, crtc->desiredY))
                     return FALSE;
       }
       return TRUE;
}

Here is the caller graph for this function:

Bool drmmode_setup_colormap ( ScreenPtr  pScreen,
ScrnInfoPtr  pScrn 
)

Definition at line 1202 of file drmmode_display.c.

{
    xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 0,
                  "Initializing kms color map\n");
    if (!miCreateDefColormap(pScreen))
        return FALSE;
    /* all radeons support 10 bit CLUTs */
    if (!xf86HandleColormaps(pScreen, 256, 10,
                             drmmode_load_palette, NULL,
                             CMAP_PALETTED_TRUECOLOR
#if 0 /* This option messes up text mode! (eich@suse.de) */
                             | CMAP_LOAD_EVEN_IF_OFFSCREEN
#endif
                             | CMAP_RELOAD_ON_MODE_SWITCH))
         return FALSE;
    return TRUE;
}

Here is the call graph for this function:

void drmmode_uevent_fini ( ScrnInfoPtr  scrn,
drmmode_ptr  drmmode 
)

Definition at line 1269 of file drmmode_display.c.

{
#ifdef HAVE_UDEV
       if (drmmode->uevent_handler) {
              struct udev *u = udev_monitor_get_udev(drmmode->uevent_monitor);
              xf86RemoveGeneralHandler(drmmode->uevent_handler);

              udev_monitor_unref(drmmode->uevent_monitor);
              udev_unref(u);
       }
#endif
}

Here is the caller graph for this function:

void drmmode_uevent_init ( ScrnInfoPtr  scrn,
drmmode_ptr  drmmode 
)

Definition at line 1236 of file drmmode_display.c.

{
#ifdef HAVE_UDEV
       struct udev *u;
       struct udev_monitor *mon;

       u = udev_new();
       if (!u)
              return;
       mon = udev_monitor_new_from_netlink(u, "udev");
       if (!mon) {
              udev_unref(u);
              return;
       }

       if (udev_monitor_filter_add_match_subsystem_devtype(mon,
                                                     "drm",
                                                     "drm_minor") < 0 ||
           udev_monitor_enable_receiving(mon) < 0) {
              udev_monitor_unref(mon);
              udev_unref(u);
              return;
       }

       drmmode->uevent_handler =
              xf86AddGeneralHandler(udev_monitor_get_fd(mon),
                                  drmmode_handle_uevents,
                                  drmmode);

       drmmode->uevent_monitor = mon;
#endif
}

Here is the caller graph for this function: