Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1 | /* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */ |
| 2 | |
| 3 | /* |
| 4 | * Copyright © 2011 Texas Instruments, Inc |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice (including the next |
| 14 | * paragraph) shall be included in all copies or substantial portions of the |
| 15 | * Software. |
| 16 | * |
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 20 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 23 | * SOFTWARE. |
| 24 | * |
| 25 | * Authors: |
| 26 | * Ian Elliott <ianelliottus@yahoo.com> |
| 27 | * Rob Clark <rob@ti.com> |
| 28 | */ |
| 29 | |
Raymond Smith | 41ecf3e | 2012-05-01 14:51:34 +0100 | [diff] [blame] | 30 | #include <sys/types.h> |
| 31 | #include <sys/stat.h> |
| 32 | #include <fcntl.h> |
Dave Barnish | 1a3dac3 | 2013-06-20 19:01:38 +0100 | [diff] [blame] | 33 | #include <unistd.h> |
Raymond Smith | 41ecf3e | 2012-05-01 14:51:34 +0100 | [diff] [blame] | 34 | |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 35 | #ifdef HAVE_CONFIG_H |
| 36 | #include "config.h" |
| 37 | #endif |
| 38 | |
Paul Geary | f8b9969 | 2013-04-15 10:55:17 +0100 | [diff] [blame] | 39 | #include "armsoc_driver.h" |
Dave Barnish | 257c6f1 | 2013-06-05 17:00:29 +0100 | [diff] [blame] | 40 | |
| 41 | #include "micmap.h" |
| 42 | |
| 43 | #include "xf86cmap.h" |
| 44 | #include "xf86RandR12.h" |
| 45 | |
Cooper Yuan | a83caa6 | 2012-06-28 17:19:06 +0200 | [diff] [blame] | 46 | #include "compat-api.h" |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 47 | |
Ray Smith | 3c33c3d | 2013-03-26 16:06:37 +0000 | [diff] [blame] | 48 | #include "drmmode_driver.h" |
| 49 | |
Dave Barnish | 1a3dac3 | 2013-06-20 19:01:38 +0100 | [diff] [blame] | 50 | #define DRM_DEVICE "/dev/dri/card%d" |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 51 | |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 52 | Bool armsocDebug; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 53 | |
| 54 | /* |
| 55 | * Forward declarations: |
| 56 | */ |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 57 | static const OptionInfoRec *ARMSOCAvailableOptions(int chipid, int busid); |
| 58 | static void ARMSOCIdentify(int flags); |
| 59 | static Bool ARMSOCProbe(DriverPtr drv, int flags); |
| 60 | static Bool ARMSOCPreInit(ScrnInfoPtr pScrn, int flags); |
| 61 | static Bool ARMSOCScreenInit(SCREEN_INIT_ARGS_DECL); |
| 62 | static void ARMSOCLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 63 | LOCO *colors, VisualPtr pVisual); |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 64 | static Bool ARMSOCCloseScreen(CLOSE_SCREEN_ARGS_DECL); |
| 65 | static Bool ARMSOCCreateScreenResources(ScreenPtr pScreen); |
| 66 | static void ARMSOCBlockHandler(BLOCKHANDLER_ARGS_DECL); |
| 67 | static Bool ARMSOCSwitchMode(SWITCH_MODE_ARGS_DECL); |
| 68 | static void ARMSOCAdjustFrame(ADJUST_FRAME_ARGS_DECL); |
| 69 | static Bool ARMSOCEnterVT(VT_FUNC_ARGS_DECL); |
| 70 | static void ARMSOCLeaveVT(VT_FUNC_ARGS_DECL); |
| 71 | static void ARMSOCFreeScreen(FREE_SCREEN_ARGS_DECL); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 72 | |
| 73 | |
| 74 | |
| 75 | /** |
| 76 | * A structure used by the XFree86 code when loading this driver, so that it |
| 77 | * can access the Probe() function, and other functions/info that it uses |
| 78 | * before it calls the Probe() function. The name of this structure must be |
| 79 | * the all-upper-case version of the driver name. |
| 80 | */ |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 81 | _X_EXPORT DriverRec ARMSOC = { |
| 82 | ARMSOC_VERSION, |
| 83 | (char *)ARMSOC_DRIVER_NAME, |
| 84 | ARMSOCIdentify, |
| 85 | ARMSOCProbe, |
| 86 | ARMSOCAvailableOptions, |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 87 | NULL, |
| 88 | 0, |
| 89 | NULL, |
| 90 | #ifdef XSERVER_LIBPCIACCESS |
| 91 | NULL, |
| 92 | NULL |
| 93 | #endif |
| 94 | }; |
| 95 | |
Dave Barnish | 01b5c17 | 2013-04-10 11:01:17 +0100 | [diff] [blame] | 96 | #define MALI_4XX_CHIPSET_ID (0x0400) |
| 97 | #define MALI_T6XX_CHIPSET_ID (0x0600) |
| 98 | |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 99 | /** Supported "chipsets." */ |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 100 | static SymTabRec ARMSOCChipsets[] = { |
Dave Barnish | 01b5c17 | 2013-04-10 11:01:17 +0100 | [diff] [blame] | 101 | { MALI_4XX_CHIPSET_ID, "Mali-4XX" }, |
| 102 | { MALI_T6XX_CHIPSET_ID, "Mali-T6XX" }, |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 103 | {-1, NULL } |
| 104 | }; |
| 105 | |
| 106 | /** Supported options, as enum values. */ |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 107 | enum { |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 108 | OPTION_DEBUG, |
Dave Barnish | c50baf5 | 2012-11-29 14:39:36 +0000 | [diff] [blame] | 109 | OPTION_NO_FLIP, |
Dave Barnish | 1a3dac3 | 2013-06-20 19:01:38 +0100 | [diff] [blame] | 110 | OPTION_CARD_NUM, |
| 111 | OPTION_BUSID, |
| 112 | OPTION_DRIVERNAME, |
David Garbett | 4d37be3 | 2013-04-04 09:04:29 +0100 | [diff] [blame] | 113 | OPTION_DRI_NUM_BUF, |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 114 | }; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 115 | |
| 116 | /** Supported options. */ |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 117 | static const OptionInfoRec ARMSOCOptions[] = { |
Dave Barnish | 1a3dac3 | 2013-06-20 19:01:38 +0100 | [diff] [blame] | 118 | { OPTION_DEBUG, "Debug", OPTV_BOOLEAN, {0}, FALSE }, |
| 119 | { OPTION_NO_FLIP, "NoFlip", OPTV_BOOLEAN, {0}, FALSE }, |
| 120 | { OPTION_CARD_NUM, "DRICard", OPTV_INTEGER, {0}, FALSE }, |
| 121 | { OPTION_BUSID, "BusID", OPTV_STRING, {0}, FALSE }, |
| 122 | { OPTION_DRIVERNAME, "DriverName", OPTV_STRING, {0}, FALSE }, |
David Garbett | 4d37be3 | 2013-04-04 09:04:29 +0100 | [diff] [blame] | 123 | { OPTION_DRI_NUM_BUF, "DRI2MaxBuffers", OPTV_INTEGER, {-1}, FALSE }, |
Dave Barnish | 1a3dac3 | 2013-06-20 19:01:38 +0100 | [diff] [blame] | 124 | { -1, NULL, OPTV_NONE, {0}, FALSE } |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 125 | }; |
| 126 | |
| 127 | /** |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 128 | * Helper functions for sharing a DRM connection across screens. |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 129 | */ |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 130 | static struct ARMSOCConnection { |
Ray Smith | b31657f | 2013-06-25 11:47:36 +0100 | [diff] [blame] | 131 | const char *driver_name; |
| 132 | const char *bus_id; |
Dave Barnish | 1a3dac3 | 2013-06-20 19:01:38 +0100 | [diff] [blame] | 133 | unsigned int card_num; |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 134 | int fd; |
| 135 | int open_count; |
| 136 | int master_count; |
Dave Barnish | 1a3dac3 | 2013-06-20 19:01:38 +0100 | [diff] [blame] | 137 | } connection = {NULL, NULL, 0, -1, 0, 0}; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 138 | |
| 139 | static int |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 140 | ARMSOCSetDRMMaster(void) |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 141 | { |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 142 | int ret = 0; |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 143 | |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 144 | assert(connection.fd >= 0); |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 145 | |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 146 | if (!connection.master_count) |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 147 | ret = drmSetMaster(connection.fd); |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 148 | |
| 149 | if (!ret) |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 150 | connection.master_count++; |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 151 | |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 152 | return ret; |
| 153 | } |
| 154 | |
| 155 | static int |
| 156 | ARMSOCDropDRMMaster(void) |
| 157 | { |
| 158 | int ret = 0; |
| 159 | |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 160 | assert(connection.fd >= 0); |
| 161 | assert(connection.master_count > 0); |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 162 | |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 163 | if (1 == connection.master_count) |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 164 | ret = drmDropMaster(connection.fd); |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 165 | |
| 166 | if (!ret) |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 167 | connection.master_count--; |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 168 | |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 169 | return ret; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 170 | } |
| 171 | |
Dave Barnish | 1a3dac3 | 2013-06-20 19:01:38 +0100 | [diff] [blame] | 172 | static void |
| 173 | ARMSOCShowDriverInfo(int fd) |
| 174 | { |
| 175 | char *bus_id; |
| 176 | drmVersionPtr version; |
| 177 | char *deviceName; |
| 178 | |
| 179 | EARLY_INFO_MSG("Opened DRM"); |
| 180 | deviceName = drmGetDeviceNameFromFd(fd); |
| 181 | EARLY_INFO_MSG(" DeviceName is [%s]", |
| 182 | deviceName ? deviceName : "NULL"); |
| 183 | drmFree(deviceName); |
| 184 | bus_id = drmGetBusid(fd); |
| 185 | EARLY_INFO_MSG(" bus_id is [%s]", |
| 186 | bus_id ? bus_id : "NULL"); |
| 187 | drmFreeBusid(bus_id); |
| 188 | version = drmGetVersion(fd); |
| 189 | if (version) { |
| 190 | EARLY_INFO_MSG(" DriverName is [%s]", |
| 191 | version->name); |
| 192 | EARLY_INFO_MSG(" version is [%d.%d.%d]", |
| 193 | version->version_major, |
| 194 | version->version_minor, |
| 195 | version->version_patchlevel); |
| 196 | drmFreeVersion(version); |
| 197 | } else { |
| 198 | EARLY_INFO_MSG(" version is [NULL]"); |
| 199 | } |
| 200 | return; |
| 201 | } |
| 202 | |
| 203 | static int |
| 204 | ARMSOCOpenDRMCard(void) |
| 205 | { |
| 206 | int fd; |
| 207 | |
| 208 | if ((connection.bus_id) || (connection.driver_name)) { |
| 209 | /* user specified bus ID or driver name - pass to drmOpen */ |
| 210 | EARLY_INFO_MSG("Opening driver [%s], bus_id [%s]", |
| 211 | connection.driver_name ? |
| 212 | connection.driver_name : "NULL", |
| 213 | connection.bus_id ? |
| 214 | connection.bus_id : "NULL"); |
| 215 | fd = drmOpen(connection.driver_name, connection.bus_id); |
Dave Barnish | dd94805 | 2013-06-25 16:52:37 +0100 | [diff] [blame] | 216 | if (fd < 0) |
Dave Barnish | 1a3dac3 | 2013-06-20 19:01:38 +0100 | [diff] [blame] | 217 | goto fail2; |
| 218 | } else { |
| 219 | char filename[32]; |
| 220 | int err; |
| 221 | drmSetVersion sv; |
| 222 | char *bus_id, *bus_id_copy; |
| 223 | |
| 224 | /* open with card_num */ |
| 225 | snprintf(filename, sizeof(filename), |
| 226 | DRM_DEVICE, connection.card_num); |
| 227 | EARLY_INFO_MSG( |
| 228 | "No BusID or DriverName specified - opening %s", |
| 229 | filename); |
| 230 | fd = open(filename, O_RDWR, 0); |
| 231 | if (-1 == fd) |
| 232 | goto fail2; |
| 233 | /* Set interface version to initialise bus id */ |
| 234 | sv.drm_di_major = 1; |
| 235 | sv.drm_di_minor = 1; |
| 236 | sv.drm_dd_major = -1; |
| 237 | sv.drm_dd_minor = -1; |
| 238 | err = drmSetInterfaceVersion(fd, &sv); |
| 239 | if (err) { |
| 240 | EARLY_ERROR_MSG( |
| 241 | "Cannot set the DRM interface version."); |
| 242 | goto fail1; |
| 243 | } |
| 244 | /* get the bus id */ |
| 245 | bus_id = drmGetBusid(fd); |
| 246 | if (!bus_id) { |
| 247 | EARLY_ERROR_MSG("Couldn't get BusID from %s", |
| 248 | filename); |
| 249 | goto fail1; |
| 250 | } |
| 251 | EARLY_INFO_MSG("Got BusID %s", bus_id); |
| 252 | bus_id_copy = malloc(strlen(bus_id)+1); |
| 253 | if (!bus_id_copy) { |
| 254 | EARLY_ERROR_MSG("Memory alloc failed"); |
| 255 | goto fail1; |
| 256 | } |
| 257 | strcpy(bus_id_copy, bus_id); |
| 258 | drmFreeBusid(bus_id); |
| 259 | err = close(fd); |
| 260 | if (err) { |
| 261 | free(bus_id_copy); |
Dave Barnish | dd94805 | 2013-06-25 16:52:37 +0100 | [diff] [blame] | 262 | EARLY_ERROR_MSG("Couldn't close %s", filename); |
Dave Barnish | 1a3dac3 | 2013-06-20 19:01:38 +0100 | [diff] [blame] | 263 | goto fail2; |
| 264 | } |
| 265 | /* use bus_id to open driver */ |
| 266 | fd = drmOpen(NULL, bus_id_copy); |
| 267 | free(bus_id_copy); |
Dave Barnish | dd94805 | 2013-06-25 16:52:37 +0100 | [diff] [blame] | 268 | if (fd < 0) |
Dave Barnish | 1a3dac3 | 2013-06-20 19:01:38 +0100 | [diff] [blame] | 269 | goto fail2; |
| 270 | } |
| 271 | ARMSOCShowDriverInfo(fd); |
| 272 | return fd; |
| 273 | |
| 274 | fail1: |
| 275 | close(fd); |
| 276 | fail2: |
Dave Barnish | dd94805 | 2013-06-25 16:52:37 +0100 | [diff] [blame] | 277 | EARLY_ERROR_MSG( |
| 278 | "Cannot open a connection with the DRM - %s", |
| 279 | strerror(errno)); |
Dave Barnish | 1a3dac3 | 2013-06-20 19:01:38 +0100 | [diff] [blame] | 280 | return -1; |
| 281 | } |
| 282 | |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 283 | static Bool |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 284 | ARMSOCOpenDRM(ScrnInfoPtr pScrn) |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 285 | { |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 286 | struct ARMSOCRec *pARMSOC = ARMSOCPTR(pScrn); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 287 | drmSetVersion sv; |
| 288 | int err; |
| 289 | |
Dave Barnish | dd94805 | 2013-06-25 16:52:37 +0100 | [diff] [blame] | 290 | if (connection.fd < 0) { |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 291 | assert(!connection.open_count); |
| 292 | assert(!connection.master_count); |
Dave Barnish | 1a3dac3 | 2013-06-20 19:01:38 +0100 | [diff] [blame] | 293 | pARMSOC->drmFD = ARMSOCOpenDRMCard(); |
Dave Barnish | dd94805 | 2013-06-25 16:52:37 +0100 | [diff] [blame] | 294 | if (pARMSOC->drmFD < 0) |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 295 | return FALSE; |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 296 | /* Check that what we are or can become drm master by |
| 297 | * attempting a drmSetInterfaceVersion(). If successful |
| 298 | * this leaves us as master. |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 299 | * (see DRIOpenDRMMaster() in DRI1) |
| 300 | */ |
| 301 | sv.drm_di_major = 1; |
| 302 | sv.drm_di_minor = 1; |
| 303 | sv.drm_dd_major = -1; |
| 304 | sv.drm_dd_minor = -1; |
| 305 | err = drmSetInterfaceVersion(pARMSOC->drmFD, &sv); |
| 306 | if (err != 0) { |
| 307 | ERROR_MSG("Cannot set the DRM interface version."); |
| 308 | drmClose(pARMSOC->drmFD); |
| 309 | pARMSOC->drmFD = -1; |
| 310 | return FALSE; |
| 311 | } |
| 312 | connection.fd = pARMSOC->drmFD; |
| 313 | connection.open_count = 1; |
| 314 | connection.master_count = 1; |
Ray Smith | 04af999 | 2013-06-26 13:44:54 +0100 | [diff] [blame] | 315 | drmmode_init_wakeup_handler(connection.fd); |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 316 | } else { |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 317 | assert(connection.open_count); |
| 318 | connection.open_count++; |
| 319 | connection.master_count++; |
| 320 | pARMSOC->drmFD = connection.fd; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 321 | } |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 322 | pARMSOC->deviceName = drmGetDeviceNameFromFd(pARMSOC->drmFD); |
Rob Clark | 4b8f30a | 2011-08-28 12:51:26 -0500 | [diff] [blame] | 323 | |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 324 | return TRUE; |
| 325 | } |
| 326 | |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 327 | /** |
| 328 | * Helper function for closing a connection to the DRM. |
| 329 | */ |
| 330 | static void |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 331 | ARMSOCCloseDRM(ScrnInfoPtr pScrn) |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 332 | { |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 333 | struct ARMSOCRec *pARMSOC = ARMSOCPTR(pScrn); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 334 | |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 335 | if (pARMSOC && (pARMSOC->drmFD >= 0)) { |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 336 | drmFree(pARMSOC->deviceName); |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 337 | connection.open_count--; |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 338 | if (!connection.open_count) { |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 339 | assert(!connection.master_count); |
Ray Smith | 04af999 | 2013-06-26 13:44:54 +0100 | [diff] [blame] | 340 | drmmode_fini_wakeup_handler(connection.fd); |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 341 | drmClose(pARMSOC->drmFD); |
| 342 | connection.fd = -1; |
| 343 | } |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 344 | pARMSOC->drmFD = -1; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 345 | } |
| 346 | } |
| 347 | |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 348 | /** Let the XFree86 code know the Setup() function. */ |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 349 | static MODULESETUPPROTO(ARMSOCSetup); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 350 | |
| 351 | /** Provide basic version information to the XFree86 code. */ |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 352 | static XF86ModuleVersionInfo ARMSOCVersRec = { |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 353 | ARMSOC_DRIVER_NAME, |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 354 | MODULEVENDORSTRING, |
| 355 | MODINFOSTRING1, |
| 356 | MODINFOSTRING2, |
| 357 | XORG_VERSION_CURRENT, |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 358 | PACKAGE_VERSION_MAJOR, |
| 359 | PACKAGE_VERSION_MINOR, |
| 360 | PACKAGE_VERSION_PATCHLEVEL, |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 361 | ABI_CLASS_VIDEODRV, |
| 362 | ABI_VIDEODRV_VERSION, |
| 363 | MOD_CLASS_VIDEODRV, |
| 364 | {0, 0, 0, 0} |
| 365 | }; |
| 366 | |
| 367 | /** Let the XFree86 code know about the VersRec and Setup() function. */ |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 368 | _X_EXPORT XF86ModuleData armsocModuleData = { &ARMSOCVersRec, ARMSOCSetup, NULL }; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 369 | |
| 370 | |
| 371 | /** |
| 372 | * The first function that the XFree86 code calls, after loading this module. |
| 373 | */ |
| 374 | static pointer |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 375 | ARMSOCSetup(pointer module, pointer opts, int *errmaj, int *errmin) |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 376 | { |
| 377 | static Bool setupDone = FALSE; |
| 378 | |
| 379 | /* This module should be loaded only once, but check to be sure: */ |
| 380 | if (!setupDone) { |
| 381 | setupDone = TRUE; |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 382 | xf86AddDriver(&ARMSOC, module, 0); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 383 | |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 384 | /* The return value must be non-NULL on success even |
| 385 | * though there is no TearDownProc. |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 386 | */ |
| 387 | return (pointer) 1; |
| 388 | } else { |
| 389 | if (errmaj) |
| 390 | *errmaj = LDR_ONCEONLY; |
| 391 | return NULL; |
| 392 | } |
| 393 | } |
| 394 | |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 395 | /** |
| 396 | * The mandatory AvailableOptions() function. It returns the available driver |
| 397 | * options to the "-configure" option, so that an xorg.conf file can be built |
| 398 | * and the user can see which options are available for them to use. |
| 399 | */ |
| 400 | static const OptionInfoRec * |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 401 | ARMSOCAvailableOptions(int chipid, int busid) |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 402 | { |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 403 | return ARMSOCOptions; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 404 | } |
| 405 | |
| 406 | |
| 407 | |
| 408 | /** |
| 409 | * The mandatory Identify() function. It is run before Probe(), and prints out |
| 410 | * an identifying message, which includes the chipset(s) the driver supports. |
| 411 | */ |
| 412 | static void |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 413 | ARMSOCIdentify(int flags) |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 414 | { |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 415 | xf86PrintChipsets(ARMSOC_NAME, "Driver for ARM compatible chipsets", |
| 416 | ARMSOCChipsets); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | |
| 420 | |
| 421 | /** |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 422 | * The driver's Probe() function. This function finds all instances of |
| 423 | * ARM hardware that the driver supports (from within the "xorg.conf" |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 424 | * device sections), and for instances not already claimed by another driver, |
| 425 | * claim the instances, and allocate a ScrnInfoRec. Only minimal hardware |
| 426 | * probing is allowed here. |
| 427 | */ |
| 428 | static Bool |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 429 | ARMSOCProbe(DriverPtr drv, int flags) |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 430 | { |
| 431 | int i; |
| 432 | ScrnInfoPtr pScrn; |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 433 | GDevPtr *devSections = NULL; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 434 | int numDevSections; |
| 435 | Bool foundScreen = FALSE; |
| 436 | |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 437 | /* Get the "xorg.conf" file device sections that match this driver, and |
| 438 | * return (error out) if there are none: |
| 439 | */ |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 440 | numDevSections = xf86MatchDevice(ARMSOC_DRIVER_NAME, &devSections); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 441 | if (numDevSections <= 0) { |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 442 | EARLY_ERROR_MSG( |
| 443 | "Did not find any matching device section in configuration file"); |
Rob Clark | 83f49e0 | 2012-01-08 17:31:59 -0600 | [diff] [blame] | 444 | if (flags & PROBE_DETECT) { |
| 445 | /* if we are probing, assume one and lets see if we can |
| 446 | * open the device to confirm it is there: |
| 447 | */ |
| 448 | numDevSections = 1; |
| 449 | } else { |
| 450 | return FALSE; |
| 451 | } |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 452 | } |
| 453 | |
| 454 | for (i = 0; i < numDevSections; i++) { |
Dave Barnish | 1a3dac3 | 2013-06-20 19:01:38 +0100 | [diff] [blame] | 455 | int fd; |
| 456 | |
| 457 | if (devSections) { |
Ray Smith | b31657f | 2013-06-25 11:47:36 +0100 | [diff] [blame] | 458 | const char *busIdStr; |
| 459 | const char *driverNameStr; |
| 460 | const char *cardNumStr; |
Dave Barnish | 1a3dac3 | 2013-06-20 19:01:38 +0100 | [diff] [blame] | 461 | |
| 462 | /* get the Bus ID */ |
| 463 | busIdStr = xf86FindOptionValue( |
| 464 | devSections[i]->options, |
| 465 | "BusID"); |
| 466 | |
| 467 | /* get the DriverName */ |
| 468 | driverNameStr = xf86FindOptionValue( |
| 469 | devSections[i]->options, |
| 470 | "DriverName"); |
| 471 | |
| 472 | /* get the card_num from xorg.conf if present */ |
| 473 | cardNumStr = xf86FindOptionValue( |
| 474 | devSections[i]->options, |
| 475 | "DRICard"); |
| 476 | |
| 477 | if (busIdStr && driverNameStr) { |
| 478 | EARLY_WARNING_MSG( |
| 479 | "Option DriverName ignored (BusID is specified)"); |
| 480 | } |
| 481 | if (busIdStr || driverNameStr) { |
| 482 | if (cardNumStr) { |
| 483 | EARLY_WARNING_MSG( |
| 484 | "Option DRICard ignored (BusID or DriverName are specified)"); |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | if (busIdStr) { |
| 489 | if (0 == strlen(busIdStr)) { |
| 490 | EARLY_ERROR_MSG( |
| 491 | "Missing value for Option BusID"); |
| 492 | return FALSE; |
| 493 | } |
| 494 | connection.bus_id = busIdStr; |
| 495 | } else if (driverNameStr) { |
| 496 | if (0 == strlen(driverNameStr)) { |
| 497 | EARLY_ERROR_MSG( |
| 498 | "Missing value for Option DriverName"); |
| 499 | return FALSE; |
| 500 | } |
Ray Smith | b31657f | 2013-06-25 11:47:36 +0100 | [diff] [blame] | 501 | connection.driver_name = driverNameStr; |
Dave Barnish | 1a3dac3 | 2013-06-20 19:01:38 +0100 | [diff] [blame] | 502 | } else if (cardNumStr) { |
| 503 | char *endptr; |
| 504 | errno = 0; |
| 505 | connection.card_num = strtol(cardNumStr, |
| 506 | &endptr, 10); |
| 507 | if (('\0' == *cardNumStr) || |
| 508 | ('\0' != *endptr) || |
| 509 | (errno != 0)) { |
| 510 | EARLY_ERROR_MSG( |
| 511 | "Bad Option DRICard value : %s", |
| 512 | cardNumStr); |
| 513 | return FALSE; |
| 514 | } |
| 515 | } |
| 516 | } |
| 517 | fd = ARMSOCOpenDRMCard(); |
Dave Barnish | dd94805 | 2013-06-25 16:52:37 +0100 | [diff] [blame] | 518 | if (fd >= 0) { |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 519 | struct ARMSOCRec *pARMSOC; |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 520 | |
| 521 | /* Allocate the ScrnInfoRec */ |
| 522 | pScrn = xf86AllocateScreen(drv, 0); |
| 523 | if (!pScrn) { |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 524 | EARLY_ERROR_MSG( |
| 525 | "Cannot allocate a ScrnInfoPtr"); |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 526 | return FALSE; |
| 527 | } |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 528 | /* Allocate the driver's Screen-specific, "private" |
| 529 | * data structure and hook it into the ScrnInfoRec's |
| 530 | * driverPrivate field. |
| 531 | */ |
| 532 | pScrn->driverPrivate = |
| 533 | calloc(1, sizeof(struct ARMSOCRec)); |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 534 | if (!pScrn->driverPrivate) |
| 535 | return FALSE; |
| 536 | |
| 537 | pARMSOC = ARMSOCPTR(pScrn); |
Dave Barnish | 1a3dac3 | 2013-06-20 19:01:38 +0100 | [diff] [blame] | 538 | /* initially mark to use all DRM crtcs */ |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 539 | pARMSOC->crtcNum = -1; |
Rob Clark | 83f49e0 | 2012-01-08 17:31:59 -0600 | [diff] [blame] | 540 | |
| 541 | if (flags & PROBE_DETECT) { |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 542 | /* just add the device.. we aren't a PCI device, |
| 543 | * so call xf86AddBusDeviceToConfigure() |
| 544 | * directly |
Rob Clark | 83f49e0 | 2012-01-08 17:31:59 -0600 | [diff] [blame] | 545 | */ |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 546 | xf86AddBusDeviceToConfigure(ARMSOC_DRIVER_NAME, |
Rob Clark | 83f49e0 | 2012-01-08 17:31:59 -0600 | [diff] [blame] | 547 | BUS_NONE, NULL, i); |
| 548 | foundScreen = TRUE; |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 549 | drmClose(fd); |
Rob Clark | 83f49e0 | 2012-01-08 17:31:59 -0600 | [diff] [blame] | 550 | continue; |
| 551 | } |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 552 | |
Rob Clark | 83f49e0 | 2012-01-08 17:31:59 -0600 | [diff] [blame] | 553 | if (devSections) { |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 554 | int entity = xf86ClaimNoSlot(drv, 0, |
| 555 | devSections[i], TRUE); |
Rob Clark | 83f49e0 | 2012-01-08 17:31:59 -0600 | [diff] [blame] | 556 | xf86AddEntityToScreen(pScrn, entity); |
| 557 | } |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 558 | |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 559 | /* if there are multiple screens, use a separate |
| 560 | * crtc for each one |
| 561 | */ |
| 562 | if (numDevSections > 1) |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 563 | pARMSOC->crtcNum = i; |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 564 | |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 565 | xf86Msg(X_INFO, "Screen:%d, CRTC:%d\n", |
| 566 | pScrn->scrnIndex, |
| 567 | pARMSOC->crtcNum); |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 568 | |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 569 | foundScreen = TRUE; |
| 570 | |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 571 | pScrn->driverVersion = ARMSOC_VERSION; |
| 572 | pScrn->driverName = (char *)ARMSOC_DRIVER_NAME; |
| 573 | pScrn->name = (char *)ARMSOC_NAME; |
| 574 | pScrn->Probe = ARMSOCProbe; |
| 575 | pScrn->PreInit = ARMSOCPreInit; |
| 576 | pScrn->ScreenInit = ARMSOCScreenInit; |
| 577 | pScrn->SwitchMode = ARMSOCSwitchMode; |
| 578 | pScrn->AdjustFrame = ARMSOCAdjustFrame; |
| 579 | pScrn->EnterVT = ARMSOCEnterVT; |
| 580 | pScrn->LeaveVT = ARMSOCLeaveVT; |
| 581 | pScrn->FreeScreen = ARMSOCFreeScreen; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 582 | |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 583 | /* would be nice to keep the connection open */ |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 584 | drmClose(fd); |
| 585 | } |
| 586 | } |
| 587 | free(devSections); |
| 588 | return foundScreen; |
| 589 | } |
| 590 | |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 591 | /** |
| 592 | * The driver's PreInit() function. Additional hardware probing is allowed |
| 593 | * now, including display configuration. |
| 594 | */ |
| 595 | static Bool |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 596 | ARMSOCPreInit(ScrnInfoPtr pScrn, int flags) |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 597 | { |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 598 | struct ARMSOCRec *pARMSOC; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 599 | int default_depth, fbbpp; |
| 600 | rgb defaultWeight = { 0, 0, 0 }; |
| 601 | rgb defaultMask = { 0, 0, 0 }; |
| 602 | Gamma defaultGamma = { 0.0, 0.0, 0.0 }; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 603 | int i; |
David Garbett | 4d37be3 | 2013-04-04 09:04:29 +0100 | [diff] [blame] | 604 | int driNumBufs; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 605 | |
| 606 | TRACE_ENTER(); |
| 607 | |
| 608 | if (flags & PROBE_DETECT) { |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 609 | ERROR_MSG( |
| 610 | "The %s driver does not support the \"-configure\" or \"-probe\" command line arguments.", |
| 611 | ARMSOC_NAME); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 612 | return FALSE; |
| 613 | } |
| 614 | |
| 615 | /* Check the number of entities, and fail if it isn't one. */ |
| 616 | if (pScrn->numEntities != 1) { |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 617 | ERROR_MSG( |
| 618 | "Driver expected 1 entity, but found %d for screen %d", |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 619 | pScrn->numEntities, pScrn->scrnIndex); |
| 620 | return FALSE; |
| 621 | } |
| 622 | |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 623 | pARMSOC = ARMSOCPTR(pScrn); |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 624 | pARMSOC->pEntityInfo = xf86GetEntityInfo(pScrn->entityList[0]); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 625 | |
| 626 | pScrn->monitor = pScrn->confScreen->monitor; |
| 627 | |
| 628 | /* Get the current depth, and set it for XFree86: */ |
Dave Barnish | 2742d15 | 2013-03-13 13:36:58 +0000 | [diff] [blame] | 629 | default_depth = 24; /* TODO: MIDEGL-1445: get from kernel */ |
| 630 | fbbpp = 32; /* TODO: MIDEGL-1445: get from kernel */ |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 631 | |
| 632 | if (!xf86SetDepthBpp(pScrn, default_depth, 0, fbbpp, Support32bppFb)) { |
| 633 | /* The above function prints an error message. */ |
| 634 | goto fail; |
| 635 | } |
| 636 | xf86PrintDepthBpp(pScrn); |
| 637 | |
| 638 | /* Set the color weight: */ |
| 639 | if (!xf86SetWeight(pScrn, defaultWeight, defaultMask)) { |
| 640 | /* The above function prints an error message. */ |
| 641 | goto fail; |
| 642 | } |
| 643 | |
| 644 | /* Set the gamma: */ |
| 645 | if (!xf86SetGamma(pScrn, defaultGamma)) { |
| 646 | /* The above function prints an error message. */ |
| 647 | goto fail; |
| 648 | } |
| 649 | |
| 650 | /* Visual init: */ |
| 651 | if (!xf86SetDefaultVisual(pScrn, -1)) { |
| 652 | /* The above function prints an error message. */ |
| 653 | goto fail; |
| 654 | } |
| 655 | |
| 656 | /* We don't support 8-bit depths: */ |
| 657 | if (pScrn->depth < 16) { |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 658 | ERROR_MSG( |
| 659 | "The requested default visual (%s) has an unsupported depth (%d).", |
| 660 | xf86GetVisualName(pScrn->defaultVisual), |
| 661 | pScrn->depth); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 662 | goto fail; |
| 663 | } |
| 664 | |
| 665 | /* Using a programmable clock: */ |
| 666 | pScrn->progClock = TRUE; |
| 667 | |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 668 | /* Open a connection to the DRM, so we can communicate |
| 669 | * with the KMS code: |
| 670 | */ |
| 671 | if (!ARMSOCOpenDRM(pScrn)) |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 672 | goto fail; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 673 | |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 674 | pARMSOC->drmmode_interface = |
| 675 | drmmode_interface_get_implementation(pARMSOC->drmFD); |
Dave Barnish | de45ed4 | 2013-06-05 13:47:56 +0100 | [diff] [blame] | 676 | if (!pARMSOC->drmmode_interface) |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 677 | goto fail2; |
Ray Smith | 3c33c3d | 2013-03-26 16:06:37 +0000 | [diff] [blame] | 678 | |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 679 | /* create DRM device instance: */ |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 680 | pARMSOC->dev = armsoc_device_new(pARMSOC->drmFD, |
Javier Martin | 981264d | 2013-08-21 16:48:07 +0100 | [diff] [blame] | 681 | pARMSOC->drmmode_interface->create_custom_gem); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 682 | |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 683 | /* find matching chipset name: */ |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 684 | for (i = 0; ARMSOCChipsets[i].name; i++) { |
| 685 | if (ARMSOCChipsets[i].token == MALI_T6XX_CHIPSET_ID) { |
| 686 | pScrn->chipset = (char *)ARMSOCChipsets[i].name; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 687 | break; |
| 688 | } |
| 689 | } |
| 690 | |
Dave Barnish | 01b5c17 | 2013-04-10 11:01:17 +0100 | [diff] [blame] | 691 | INFO_MSG("Chipset: %s", pScrn->chipset); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 692 | |
| 693 | /* |
| 694 | * Process the "xorg.conf" file options: |
| 695 | */ |
| 696 | xf86CollectOptions(pScrn, NULL); |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 697 | pARMSOC->pOptionInfo = calloc(1, sizeof(ARMSOCOptions)); |
| 698 | if (!pARMSOC->pOptionInfo) |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 699 | goto fail2; |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 700 | |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 701 | memcpy(pARMSOC->pOptionInfo, ARMSOCOptions, sizeof(ARMSOCOptions)); |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 702 | xf86ProcessOptions(pScrn->scrnIndex, |
| 703 | pARMSOC->pEntityInfo->device->options, |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 704 | pARMSOC->pOptionInfo); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 705 | |
| 706 | /* Determine if the user wants debug messages turned on: */ |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 707 | armsocDebug = xf86ReturnOptValBool(pARMSOC->pOptionInfo, |
| 708 | OPTION_DEBUG, FALSE); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 709 | |
David Garbett | 4d37be3 | 2013-04-04 09:04:29 +0100 | [diff] [blame] | 710 | if (!xf86GetOptValInteger(pARMSOC->pOptionInfo, OPTION_DRI_NUM_BUF, |
| 711 | &driNumBufs)) { |
| 712 | /* Default to double buffering */ |
| 713 | driNumBufs = 2; |
| 714 | } |
| 715 | |
| 716 | if (driNumBufs < 2) { |
| 717 | ERROR_MSG( |
| 718 | "Invalid option for %s: %d. Must be greater than or equal to 2", |
| 719 | xf86TokenToOptName(pARMSOC->pOptionInfo, |
| 720 | OPTION_DRI_NUM_BUF), |
| 721 | driNumBufs); |
| 722 | return FALSE; |
| 723 | } |
| 724 | pARMSOC->driNumBufs = driNumBufs; |
Dave Barnish | c50baf5 | 2012-11-29 14:39:36 +0000 | [diff] [blame] | 725 | /* Determine if user wants to disable buffer flipping: */ |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 726 | pARMSOC->NoFlip = xf86ReturnOptValBool(pARMSOC->pOptionInfo, |
Dave Barnish | c50baf5 | 2012-11-29 14:39:36 +0000 | [diff] [blame] | 727 | OPTION_NO_FLIP, FALSE); |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 728 | INFO_MSG("Buffer Flipping is %s", |
| 729 | pARMSOC->NoFlip ? "Disabled" : "Enabled"); |
Dave Barnish | c50baf5 | 2012-11-29 14:39:36 +0000 | [diff] [blame] | 730 | |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 731 | /* |
| 732 | * Select the video modes: |
| 733 | */ |
| 734 | INFO_MSG("Setting the video modes ..."); |
| 735 | |
| 736 | /* Don't call drmCheckModesettingSupported() as its written only for |
| 737 | * PCI devices. |
| 738 | */ |
| 739 | |
| 740 | /* Do initial KMS setup: */ |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 741 | if (!drmmode_pre_init(pScrn, pARMSOC->drmFD, |
| 742 | (pScrn->bitsPerPixel >> 3))) { |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 743 | ERROR_MSG("Cannot get KMS resources"); |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 744 | goto fail2; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 745 | } else { |
| 746 | INFO_MSG("Got KMS resources"); |
| 747 | } |
| 748 | |
| 749 | xf86RandR12PreInit(pScrn); |
| 750 | |
| 751 | /* Let XFree86 calculate or get (from command line) the display DPI: */ |
| 752 | xf86SetDpi(pScrn, 0, 0); |
| 753 | |
| 754 | /* Ensure we have a supported depth: */ |
| 755 | switch (pScrn->bitsPerPixel) { |
| 756 | case 16: |
| 757 | case 24: |
| 758 | case 32: |
| 759 | break; |
| 760 | default: |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 761 | ERROR_MSG( |
| 762 | "The requested number of bits per pixel (%d) is unsupported.", |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 763 | pScrn->bitsPerPixel); |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 764 | goto fail2; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 765 | } |
| 766 | |
| 767 | |
| 768 | /* Load external sub-modules now: */ |
| 769 | |
| 770 | if (!(xf86LoadSubModule(pScrn, "dri2") && |
| 771 | xf86LoadSubModule(pScrn, "exa") && |
| 772 | xf86LoadSubModule(pScrn, "fb"))) { |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 773 | goto fail2; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 774 | } |
| 775 | |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 776 | TRACE_EXIT(); |
| 777 | return TRUE; |
| 778 | |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 779 | fail2: |
| 780 | /* Cleanup here where we know whether we took a connection |
| 781 | * instead of in FreeScreen where we don't */ |
| 782 | ARMSOCDropDRMMaster(); |
| 783 | ARMSOCCloseDRM(pScrn); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 784 | fail: |
| 785 | TRACE_EXIT(); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 786 | return FALSE; |
| 787 | } |
| 788 | |
| 789 | |
Rob Clark | dc9dfae | 2012-01-11 18:20:18 -0600 | [diff] [blame] | 790 | /** |
| 791 | * Initialize EXA and DRI2 |
| 792 | */ |
| 793 | static void |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 794 | ARMSOCAccelInit(ScreenPtr pScreen) |
Rob Clark | dc9dfae | 2012-01-11 18:20:18 -0600 | [diff] [blame] | 795 | { |
| 796 | ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 797 | struct ARMSOCRec *pARMSOC = ARMSOCPTR(pScrn); |
Rob Clark | dc9dfae | 2012-01-11 18:20:18 -0600 | [diff] [blame] | 798 | |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 799 | if (!pARMSOC->pARMSOCEXA) |
| 800 | pARMSOC->pARMSOCEXA = InitNullEXA(pScreen, pScrn, |
| 801 | pARMSOC->drmFD); |
Rob Clark | dc9dfae | 2012-01-11 18:20:18 -0600 | [diff] [blame] | 802 | |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 803 | if (pARMSOC->pARMSOCEXA) |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 804 | pARMSOC->dri = ARMSOCDRI2ScreenInit(pScreen); |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 805 | else |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 806 | pARMSOC->dri = FALSE; |
Rob Clark | dc9dfae | 2012-01-11 18:20:18 -0600 | [diff] [blame] | 807 | } |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 808 | |
| 809 | /** |
Dave Barnish | fd50b13 | 2013-05-16 15:00:02 +0100 | [diff] [blame] | 810 | * The driver's ScreenInit() function, called at the start of each server |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 811 | * generation. Fill in pScreen, map the frame buffer, save state, |
Dave Barnish | fd50b13 | 2013-05-16 15:00:02 +0100 | [diff] [blame] | 812 | * initialize the mode, etc. |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 813 | */ |
| 814 | static Bool |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 815 | ARMSOCScreenInit(SCREEN_INIT_ARGS_DECL) |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 816 | { |
| 817 | ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; |
Dave Barnish | dd94805 | 2013-06-25 16:52:37 +0100 | [diff] [blame] | 818 | #ifndef XF86_SCRN_INTERFACE |
| 819 | int scrnIndex = pScrn->scrnIndex; |
| 820 | #endif |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 821 | struct ARMSOCRec *pARMSOC = ARMSOCPTR(pScrn); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 822 | VisualPtr visual; |
| 823 | xf86CrtcConfigPtr xf86_config; |
David Garbett | 82b5183 | 2012-07-04 08:29:38 +0100 | [diff] [blame] | 824 | int j; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 825 | |
| 826 | TRACE_ENTER(); |
| 827 | |
Dave Barnish | 982518c | 2013-04-22 16:09:22 +0100 | [diff] [blame] | 828 | /* set drm master before allocating scanout buffer */ |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 829 | if (ARMSOCSetDRMMaster()) { |
Dave Barnish | 982518c | 2013-04-22 16:09:22 +0100 | [diff] [blame] | 830 | ERROR_MSG("Cannot get DRM master: %s", strerror(errno)); |
Dave Barnish | fd50b13 | 2013-05-16 15:00:02 +0100 | [diff] [blame] | 831 | goto fail; |
Dave Barnish | 982518c | 2013-04-22 16:09:22 +0100 | [diff] [blame] | 832 | } |
Dave Barnish | 52faee0 | 2013-04-22 13:28:42 +0100 | [diff] [blame] | 833 | /* Allocate initial scanout buffer */ |
| 834 | DEBUG_MSG("allocating new scanout buffer: %dx%d", |
| 835 | pScrn->virtualX, pScrn->virtualY); |
Dave Barnish | 52faee0 | 2013-04-22 13:28:42 +0100 | [diff] [blame] | 836 | assert(!pARMSOC->scanout); |
| 837 | pARMSOC->scanout = armsoc_bo_new_with_dim(pARMSOC->dev, pScrn->virtualX, |
| 838 | pScrn->virtualY, pScrn->depth, pScrn->bitsPerPixel, |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 839 | ARMSOC_BO_SCANOUT); |
Dave Barnish | 52faee0 | 2013-04-22 13:28:42 +0100 | [diff] [blame] | 840 | if (!pARMSOC->scanout) { |
Dave Barnish | fd50b13 | 2013-05-16 15:00:02 +0100 | [diff] [blame] | 841 | ERROR_MSG("Cannot allocate scanout buffer\n"); |
| 842 | goto fail1; |
Dave Barnish | 52faee0 | 2013-04-22 13:28:42 +0100 | [diff] [blame] | 843 | } |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 844 | pScrn->displayWidth = armsoc_bo_pitch(pARMSOC->scanout) / |
| 845 | ((pScrn->bitsPerPixel+7) / 8); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 846 | xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); |
| 847 | |
| 848 | /* need to point to new screen on server regeneration */ |
David Garbett | 82b5183 | 2012-07-04 08:29:38 +0100 | [diff] [blame] | 849 | for (j = 0; j < xf86_config->num_crtc; j++) |
| 850 | xf86_config->crtc[j]->scrn = pScrn; |
| 851 | for (j = 0; j < xf86_config->num_output; j++) |
| 852 | xf86_config->output[j]->scrn = pScrn; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 853 | |
| 854 | /* |
| 855 | * The next step is to setup the screen's visuals, and initialize the |
| 856 | * framebuffer code. In cases where the framebuffer's default |
| 857 | * choices for things like visual layouts and bits per RGB are OK, |
| 858 | * this may be as simple as calling the framebuffer's ScreenInit() |
| 859 | * function. If not, the visuals will need to be setup before calling |
| 860 | * a fb ScreenInit() function and fixed up after. |
| 861 | * |
| 862 | * For most PC hardware at depths >= 8, the defaults that fb uses |
| 863 | * are not appropriate. In this driver, we fixup the visuals after. |
| 864 | */ |
| 865 | |
Dave Barnish | fd50b13 | 2013-05-16 15:00:02 +0100 | [diff] [blame] | 866 | /* Reset the visual list. */ |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 867 | miClearVisualTypes(); |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 868 | if (!miSetVisualTypes(pScrn->bitsPerPixel, |
| 869 | miGetDefaultVisualMask(pScrn->depth), |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 870 | pScrn->rgbBits, pScrn->defaultVisual)) { |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 871 | ERROR_MSG( |
| 872 | "Cannot initialize the visual type for %d bits per pixel!", |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 873 | pScrn->bitsPerPixel); |
Dave Barnish | fd50b13 | 2013-05-16 15:00:02 +0100 | [diff] [blame] | 874 | goto fail2; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 875 | } |
| 876 | |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 877 | if (pScrn->bitsPerPixel == 32 && pScrn->depth == 24) { |
David Garbett | ef4b748 | 2012-09-26 14:09:01 +0100 | [diff] [blame] | 878 | /* Also add a 24 bit depth visual */ |
| 879 | if (!miSetVisualTypes(24, miGetDefaultVisualMask(pScrn->depth), |
| 880 | pScrn->rgbBits, pScrn->defaultVisual)) { |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 881 | WARNING_MSG( |
| 882 | "Cannot initialize a 24 depth visual for 32bpp"); |
| 883 | } else { |
David Garbett | ef4b748 | 2012-09-26 14:09:01 +0100 | [diff] [blame] | 884 | INFO_MSG("Initialized a 24 depth visual for 32bpp"); |
| 885 | } |
| 886 | } |
| 887 | |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 888 | if (!miSetPixmapDepths()) { |
| 889 | ERROR_MSG("Cannot initialize the pixmap depth!"); |
Dave Barnish | fd50b13 | 2013-05-16 15:00:02 +0100 | [diff] [blame] | 890 | goto fail3; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 891 | } |
| 892 | |
| 893 | /* Initialize some generic 2D drawing functions: */ |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 894 | if (!fbScreenInit(pScreen, armsoc_bo_map(pARMSOC->scanout), |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 895 | pScrn->virtualX, pScrn->virtualY, |
| 896 | pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth, |
| 897 | pScrn->bitsPerPixel)) { |
| 898 | ERROR_MSG("fbScreenInit() failed!"); |
Dave Barnish | fd50b13 | 2013-05-16 15:00:02 +0100 | [diff] [blame] | 899 | goto fail3; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 900 | } |
| 901 | |
| 902 | /* Fixup RGB ordering: */ |
| 903 | visual = pScreen->visuals + pScreen->numVisuals; |
| 904 | while (--visual >= pScreen->visuals) { |
| 905 | if ((visual->class | DynamicClass) == DirectColor) { |
| 906 | visual->offsetRed = pScrn->offset.red; |
| 907 | visual->offsetGreen = pScrn->offset.green; |
| 908 | visual->offsetBlue = pScrn->offset.blue; |
| 909 | visual->redMask = pScrn->mask.red; |
| 910 | visual->greenMask = pScrn->mask.green; |
| 911 | visual->blueMask = pScrn->mask.blue; |
David Garbett | 100928b | 2012-10-03 14:20:54 +0100 | [diff] [blame] | 912 | visual->bitsPerRGBValue = pScrn->rgbBits; |
| 913 | visual->ColormapEntries = 1 << pScrn->rgbBits; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 914 | } |
| 915 | } |
| 916 | |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 917 | /* Continue initializing the generic 2D drawing functions after |
| 918 | * fixing the RGB ordering: |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 919 | */ |
| 920 | if (!fbPictureInit(pScreen, NULL, 0)) { |
| 921 | ERROR_MSG("fbPictureInit() failed!"); |
Dave Barnish | fd50b13 | 2013-05-16 15:00:02 +0100 | [diff] [blame] | 922 | goto fail4; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 923 | } |
| 924 | |
| 925 | /* Set the initial black & white colormap indices: */ |
| 926 | xf86SetBlackWhitePixels(pScreen); |
| 927 | |
Rob Clark | dc9dfae | 2012-01-11 18:20:18 -0600 | [diff] [blame] | 928 | /* Initialize external sub-modules for EXA now, this has to be before |
| 929 | * miDCInitialize() otherwise stacking order for wrapped ScreenPtr fxns |
| 930 | * ends up in the wrong order. |
| 931 | */ |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 932 | ARMSOCAccelInit(pScreen); |
Rob Clark | dc9dfae | 2012-01-11 18:20:18 -0600 | [diff] [blame] | 933 | |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 934 | /* Initialize backing store: */ |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 935 | xf86SetBackingStore(pScreen); |
| 936 | |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 937 | /* Enable cursor position updates by mouse signal handler: */ |
Rob Clark | 687c608 | 2012-01-08 19:33:18 -0600 | [diff] [blame] | 938 | xf86SetSilkenMouse(pScreen); |
| 939 | |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 940 | /* Initialize the cursor: */ |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 941 | if (!miDCInitialize(pScreen, xf86GetPointerScreenFuncs())) { |
Dave Barnish | fd50b13 | 2013-05-16 15:00:02 +0100 | [diff] [blame] | 942 | ERROR_MSG("miDCInitialize() failed!"); |
| 943 | goto fail5; |
Rob Clark | 687c608 | 2012-01-08 19:33:18 -0600 | [diff] [blame] | 944 | } |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 945 | |
Dave Barnish | fd50b13 | 2013-05-16 15:00:02 +0100 | [diff] [blame] | 946 | /* ignore failures here as we will fall back to software cursor */ |
| 947 | (void)drmmode_cursor_init(pScreen); |
| 948 | |
| 949 | /* TODO: MIDEGL-1458: Is this the right place for this? |
| 950 | * The Intel i830 driver says: |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 951 | * "Must force it before EnterVT, so we are in control of VT..." |
| 952 | */ |
| 953 | pScrn->vtSema = TRUE; |
| 954 | |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 955 | /* Take over the virtual terminal from the console, set the |
| 956 | * desired mode, etc.: |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 957 | */ |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 958 | if (!ARMSOCEnterVT(VT_FUNC_ARGS(0))) { |
| 959 | ERROR_MSG("ARMSOCEnterVT() failed!"); |
Dave Barnish | fd50b13 | 2013-05-16 15:00:02 +0100 | [diff] [blame] | 960 | goto fail6; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 961 | } |
| 962 | |
Dave Barnish | fd50b13 | 2013-05-16 15:00:02 +0100 | [diff] [blame] | 963 | /* Do some XRandR initialization. Return value is not useful */ |
| 964 | (void)xf86CrtcScreenInit(pScreen); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 965 | |
| 966 | if (!miCreateDefColormap(pScreen)) { |
| 967 | ERROR_MSG("Cannot create colormap!"); |
Dave Barnish | fd50b13 | 2013-05-16 15:00:02 +0100 | [diff] [blame] | 968 | goto fail7; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 969 | } |
| 970 | |
David Garbett | 100928b | 2012-10-03 14:20:54 +0100 | [diff] [blame] | 971 | if (!xf86HandleColormaps(pScreen, 1 << pScrn->rgbBits, pScrn->rgbBits, |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 972 | ARMSOCLoadPalette, NULL, CMAP_PALETTED_TRUECOLOR)) { |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 973 | ERROR_MSG("xf86HandleColormaps() failed!"); |
Dave Barnish | fd50b13 | 2013-05-16 15:00:02 +0100 | [diff] [blame] | 974 | goto fail8; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 975 | } |
| 976 | |
| 977 | /* Setup power management: */ |
| 978 | xf86DPMSInit(pScreen, xf86DPMSSet, 0); |
| 979 | |
| 980 | pScreen->SaveScreen = xf86SaveScreen; |
| 981 | |
| 982 | /* Wrap some screen functions: */ |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 983 | wrap(pARMSOC, pScreen, CloseScreen, ARMSOCCloseScreen); |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 984 | wrap(pARMSOC, pScreen, CreateScreenResources, |
| 985 | ARMSOCCreateScreenResources); |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 986 | wrap(pARMSOC, pScreen, BlockHandler, ARMSOCBlockHandler); |
Rob Clark | 4b8f30a | 2011-08-28 12:51:26 -0500 | [diff] [blame] | 987 | drmmode_screen_init(pScrn); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 988 | |
| 989 | TRACE_EXIT(); |
| 990 | return TRUE; |
| 991 | |
Dave Barnish | fd50b13 | 2013-05-16 15:00:02 +0100 | [diff] [blame] | 992 | /* cleanup on failures */ |
| 993 | fail8: |
| 994 | /* uninstall the default colormap */ |
| 995 | miUninstallColormap(GetInstalledmiColormap(pScreen)); |
| 996 | |
| 997 | fail7: |
| 998 | ARMSOCLeaveVT(VT_FUNC_ARGS(0)); |
| 999 | pScrn->vtSema = FALSE; |
| 1000 | |
| 1001 | fail6: |
| 1002 | drmmode_cursor_fini(pScreen); |
| 1003 | |
| 1004 | fail5: |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 1005 | if (pARMSOC->dri) |
Dave Barnish | fd50b13 | 2013-05-16 15:00:02 +0100 | [diff] [blame] | 1006 | ARMSOCDRI2CloseScreen(pScreen); |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 1007 | |
| 1008 | if (pARMSOC->pARMSOCEXA) |
| 1009 | if (pARMSOC->pARMSOCEXA->CloseScreen) |
Dave Barnish | dd94805 | 2013-06-25 16:52:37 +0100 | [diff] [blame] | 1010 | pARMSOC->pARMSOCEXA->CloseScreen(CLOSE_SCREEN_ARGS); |
Dave Barnish | fd50b13 | 2013-05-16 15:00:02 +0100 | [diff] [blame] | 1011 | fail4: |
| 1012 | /* Call the CloseScreen functions for fbInitScreen, miDCInitialize, |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 1013 | * exaDriverInit & xf86CrtcScreenInit as appropriate via their |
| 1014 | * wrapped pointers. |
Dave Barnish | fd50b13 | 2013-05-16 15:00:02 +0100 | [diff] [blame] | 1015 | * exaDDXCloseScreen uses the XF86SCRNINFO macro so we must |
| 1016 | * set up the key for this before it gets called. |
| 1017 | */ |
| 1018 | dixSetPrivate(&pScreen->devPrivates, xf86ScreenKey, pScrn); |
Dave Barnish | dd94805 | 2013-06-25 16:52:37 +0100 | [diff] [blame] | 1019 | (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS); |
Dave Barnish | fd50b13 | 2013-05-16 15:00:02 +0100 | [diff] [blame] | 1020 | |
| 1021 | fail3: |
| 1022 | /* reset the visual list */ |
| 1023 | miClearVisualTypes(); |
| 1024 | |
| 1025 | fail2: |
| 1026 | /* release the scanout buffer */ |
| 1027 | armsoc_bo_unreference(pARMSOC->scanout); |
| 1028 | pARMSOC->scanout = NULL; |
| 1029 | pScrn->displayWidth = 0; |
| 1030 | |
| 1031 | fail1: |
| 1032 | /* drop drm master */ |
| 1033 | (void)drmDropMaster(pARMSOC->drmFD); |
| 1034 | |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1035 | fail: |
| 1036 | TRACE_EXIT(); |
| 1037 | return FALSE; |
| 1038 | } |
| 1039 | |
| 1040 | |
| 1041 | static void |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 1042 | ARMSOCLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 1043 | LOCO *colors, VisualPtr pVisual) |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1044 | { |
| 1045 | TRACE_ENTER(); |
| 1046 | TRACE_EXIT(); |
| 1047 | } |
| 1048 | |
| 1049 | |
| 1050 | /** |
| 1051 | * The driver's CloseScreen() function. This is called at the end of each |
| 1052 | * server generation. Restore state, unmap the frame buffer (and any other |
| 1053 | * mapped memory regions), and free per-Screen data structures (except those |
| 1054 | * held by pScrn). |
| 1055 | */ |
| 1056 | static Bool |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 1057 | ARMSOCCloseScreen(CLOSE_SCREEN_ARGS_DECL) |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1058 | { |
Cooper Yuan | a83caa6 | 2012-06-28 17:19:06 +0200 | [diff] [blame] | 1059 | ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 1060 | struct ARMSOCRec *pARMSOC = ARMSOCPTR(pScrn); |
Daniel Kurtz | 22437e9 | 2013-07-30 13:28:46 +0800 | [diff] [blame^] | 1061 | Bool ret; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1062 | |
| 1063 | TRACE_ENTER(); |
| 1064 | |
Rob Clark | 4b8f30a | 2011-08-28 12:51:26 -0500 | [diff] [blame] | 1065 | drmmode_screen_fini(pScrn); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1066 | |
Daniel Kurtz | 22437e9 | 2013-07-30 13:28:46 +0800 | [diff] [blame^] | 1067 | unwrap(pARMSOC, pScreen, CloseScreen); |
| 1068 | unwrap(pARMSOC, pScreen, BlockHandler); |
| 1069 | unwrap(pARMSOC, pScreen, CreateScreenResources); |
| 1070 | |
| 1071 | ret = (*pScreen->CloseScreen)(scrnIndex, pScreen); |
| 1072 | |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 1073 | if (pARMSOC->dri) |
Dave Barnish | fd50b13 | 2013-05-16 15:00:02 +0100 | [diff] [blame] | 1074 | ARMSOCDRI2CloseScreen(pScreen); |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 1075 | |
| 1076 | if (pARMSOC->pARMSOCEXA) |
| 1077 | if (pARMSOC->pARMSOCEXA->CloseScreen) |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 1078 | pARMSOC->pARMSOCEXA->CloseScreen(CLOSE_SCREEN_ARGS); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1079 | |
Dave Barnish | 52faee0 | 2013-04-22 13:28:42 +0100 | [diff] [blame] | 1080 | /* release the scanout buffer */ |
| 1081 | armsoc_bo_unreference(pARMSOC->scanout); |
| 1082 | pARMSOC->scanout = NULL; |
| 1083 | pScrn->displayWidth = 0; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1084 | |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 1085 | if (pScrn->vtSema == TRUE) |
Dave Barnish | 982518c | 2013-04-22 16:09:22 +0100 | [diff] [blame] | 1086 | ARMSOCLeaveVT(VT_FUNC_ARGS(0)); |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 1087 | |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1088 | pScrn->vtSema = FALSE; |
| 1089 | |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1090 | TRACE_EXIT(); |
| 1091 | |
Daniel Kurtz | 22437e9 | 2013-07-30 13:28:46 +0800 | [diff] [blame^] | 1092 | return ret; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1093 | } |
| 1094 | |
| 1095 | |
| 1096 | |
| 1097 | /** |
| 1098 | * Adjust the screen pixmap for the current location of the front buffer. |
| 1099 | * This is done at EnterVT when buffers are bound as long as the resources |
| 1100 | * have already been created, but the first EnterVT happens before |
| 1101 | * CreateScreenResources. |
| 1102 | */ |
| 1103 | static Bool |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 1104 | ARMSOCCreateScreenResources(ScreenPtr pScreen) |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1105 | { |
| 1106 | ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 1107 | struct ARMSOCRec *pARMSOC = ARMSOCPTR(pScrn); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1108 | |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 1109 | swap(pARMSOC, pScreen, CreateScreenResources); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1110 | if (!(*pScreen->CreateScreenResources) (pScreen)) |
| 1111 | return FALSE; |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 1112 | swap(pARMSOC, pScreen, CreateScreenResources); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1113 | |
| 1114 | return TRUE; |
| 1115 | } |
| 1116 | |
| 1117 | |
| 1118 | static void |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 1119 | ARMSOCBlockHandler(BLOCKHANDLER_ARGS_DECL) |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1120 | { |
Cooper Yuan | a83caa6 | 2012-06-28 17:19:06 +0200 | [diff] [blame] | 1121 | SCREEN_PTR(arg); |
| 1122 | ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 1123 | struct ARMSOCRec *pARMSOC = ARMSOCPTR(pScrn); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1124 | |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 1125 | swap(pARMSOC, pScreen, BlockHandler); |
Cooper Yuan | a83caa6 | 2012-06-28 17:19:06 +0200 | [diff] [blame] | 1126 | (*pScreen->BlockHandler) (BLOCKHANDLER_ARGS); |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 1127 | swap(pARMSOC, pScreen, BlockHandler); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1128 | } |
| 1129 | |
| 1130 | |
| 1131 | |
| 1132 | /** |
| 1133 | * The driver's SwitchMode() function. Initialize the new mode for the |
| 1134 | * Screen. |
| 1135 | */ |
| 1136 | static Bool |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 1137 | ARMSOCSwitchMode(SWITCH_MODE_ARGS_DECL) |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1138 | { |
Cooper Yuan | a83caa6 | 2012-06-28 17:19:06 +0200 | [diff] [blame] | 1139 | SCRN_INFO_PTR(arg); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1140 | return xf86SetSingleMode(pScrn, mode, RR_Rotate_0); |
| 1141 | } |
| 1142 | |
| 1143 | |
| 1144 | |
| 1145 | /** |
| 1146 | * The driver's AdjustFrame() function. For cases where the frame buffer is |
| 1147 | * larger than the monitor resolution, this function can pan around the frame |
| 1148 | * buffer within the "viewport" of the monitor. |
| 1149 | */ |
| 1150 | static void |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 1151 | ARMSOCAdjustFrame(ADJUST_FRAME_ARGS_DECL) |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1152 | { |
Cooper Yuan | a83caa6 | 2012-06-28 17:19:06 +0200 | [diff] [blame] | 1153 | SCRN_INFO_PTR(arg); |
| 1154 | drmmode_adjust_frame(pScrn, x, y); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1155 | } |
| 1156 | |
| 1157 | |
| 1158 | |
| 1159 | /** |
| 1160 | * The driver's EnterVT() function. This is called at server startup time, and |
| 1161 | * when the X server takes over the virtual terminal from the console. As |
| 1162 | * such, it may need to save the current (i.e. console) HW state, and set the |
| 1163 | * HW state as needed by the X server. |
| 1164 | */ |
| 1165 | static Bool |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 1166 | ARMSOCEnterVT(VT_FUNC_ARGS_DECL) |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1167 | { |
Cooper Yuan | a83caa6 | 2012-06-28 17:19:06 +0200 | [diff] [blame] | 1168 | SCRN_INFO_PTR(arg); |
Ray Smith | 6ae735f | 2013-03-21 15:57:18 +0000 | [diff] [blame] | 1169 | int i, ret; |
abhinav.k | d4bab32 | 2012-07-31 11:29:19 -0700 | [diff] [blame] | 1170 | |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1171 | TRACE_ENTER(); |
| 1172 | |
Ray Smith | 6ae735f | 2013-03-21 15:57:18 +0000 | [diff] [blame] | 1173 | for (i = 1; i < currentMaxClients; i++) { |
| 1174 | if (clients[i]) |
| 1175 | AttendClient(clients[i]); |
| 1176 | } |
| 1177 | |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 1178 | ret = ARMSOCSetDRMMaster(); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1179 | if (ret) { |
Daniel Kurtz | 9220596 | 2013-02-05 13:50:12 +0800 | [diff] [blame] | 1180 | ERROR_MSG("Cannot get DRM master: %s", strerror(errno)); |
Daniel Kurtz | 01a91f6 | 2013-02-05 10:19:51 +0800 | [diff] [blame] | 1181 | return FALSE; |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1182 | } |
| 1183 | |
| 1184 | if (!xf86SetDesiredModes(pScrn)) { |
| 1185 | ERROR_MSG("xf86SetDesiredModes() failed!"); |
| 1186 | return FALSE; |
| 1187 | } |
| 1188 | |
| 1189 | TRACE_EXIT(); |
| 1190 | return TRUE; |
| 1191 | } |
| 1192 | |
| 1193 | |
| 1194 | |
| 1195 | /** |
| 1196 | * The driver's LeaveVT() function. This is called when the X server |
| 1197 | * temporarily gives up the virtual terminal to the console. As such, it may |
| 1198 | * need to restore the console's HW state. |
| 1199 | */ |
| 1200 | static void |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 1201 | ARMSOCLeaveVT(VT_FUNC_ARGS_DECL) |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1202 | { |
Cooper Yuan | a83caa6 | 2012-06-28 17:19:06 +0200 | [diff] [blame] | 1203 | SCRN_INFO_PTR(arg); |
Ray Smith | 6ae735f | 2013-03-21 15:57:18 +0000 | [diff] [blame] | 1204 | int i, ret; |
abhinav.k | d4bab32 | 2012-07-31 11:29:19 -0700 | [diff] [blame] | 1205 | |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1206 | TRACE_ENTER(); |
| 1207 | |
Ray Smith | 6ae735f | 2013-03-21 15:57:18 +0000 | [diff] [blame] | 1208 | for (i = 1; i < currentMaxClients; i++) { |
| 1209 | if (clients[i]) |
| 1210 | IgnoreClient(clients[i]); |
| 1211 | } |
| 1212 | |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 1213 | ret = ARMSOCDropDRMMaster(); |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 1214 | if (ret) |
Daniel Kurtz | 9220596 | 2013-02-05 13:50:12 +0800 | [diff] [blame] | 1215 | WARNING_MSG("drmDropMaster failed: %s", strerror(errno)); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1216 | |
| 1217 | TRACE_EXIT(); |
| 1218 | } |
| 1219 | |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1220 | /** |
Dave Barnish | 982518c | 2013-04-22 16:09:22 +0100 | [diff] [blame] | 1221 | * The driver's FreeScreen() function. |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 1222 | * Frees the ScrnInfoRec driverPrivate field when a screen is |
| 1223 | * deleted by the common layer. |
Dave Barnish | 982518c | 2013-04-22 16:09:22 +0100 | [diff] [blame] | 1224 | * This function is not used in normal (error free) operation. |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1225 | */ |
| 1226 | static void |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 1227 | ARMSOCFreeScreen(FREE_SCREEN_ARGS_DECL) |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1228 | { |
Cooper Yuan | a83caa6 | 2012-06-28 17:19:06 +0200 | [diff] [blame] | 1229 | SCRN_INFO_PTR(arg); |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 1230 | struct ARMSOCRec *pARMSOC = ARMSOCPTR(pScrn); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1231 | |
| 1232 | TRACE_ENTER(); |
| 1233 | |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 1234 | if (!pARMSOC) { |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1235 | /* This can happen if a Screen is deleted after Probe(): */ |
| 1236 | return; |
| 1237 | } |
| 1238 | |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 1239 | if (pARMSOC->pARMSOCEXA) { |
Dave Barnish | 2e99895 | 2013-06-11 16:31:10 +0100 | [diff] [blame] | 1240 | if (pARMSOC->pARMSOCEXA->FreeScreen) |
| 1241 | pARMSOC->pARMSOCEXA->FreeScreen( |
| 1242 | FREE_SCREEN_ARGS(pScrn)); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1243 | } |
| 1244 | |
Paul Geary | 8ffd91c | 2013-04-11 16:03:15 +0100 | [diff] [blame] | 1245 | armsoc_device_del(pARMSOC->dev); |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1246 | |
Dave Barnish | f0952c1 | 2013-05-10 15:52:23 +0100 | [diff] [blame] | 1247 | /* Free the driver's Screen-specific, "private" data structure and |
| 1248 | * NULL-out the ScrnInfoRec's driverPrivate field. |
| 1249 | */ |
| 1250 | if (pScrn->driverPrivate) { |
| 1251 | free(pScrn->driverPrivate); |
| 1252 | pScrn->driverPrivate = NULL; |
| 1253 | } |
Rob Clark | 487687e | 2011-07-17 17:29:02 -0500 | [diff] [blame] | 1254 | |
| 1255 | TRACE_EXIT(); |
| 1256 | } |
| 1257 | |