diff options
author | Alex Deucher <alexander.deucher@amd.com> | 2012-08-16 14:09:21 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2012-09-20 13:10:37 -0400 |
commit | 82e029357d4726bbfb31b4169f82dcaea5fa3eba (patch) | |
tree | e6349496f605fabd1f3bfc911fb5db210e46a1ed /drivers/gpu/drm/radeon/radeon_atpx_handler.c | |
parent | 492b49a2f21a7ce6cb0abce36017daa06036a626 (diff) |
drm/radeon: document radeon_atpx_handler.c (v2)
v2: rebase updates
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon_atpx_handler.c')
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_atpx_handler.c | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_atpx_handler.c b/drivers/gpu/drm/radeon/radeon_atpx_handler.c index 331db7a95f09..582e99449c12 100644 --- a/drivers/gpu/drm/radeon/radeon_atpx_handler.c +++ b/drivers/gpu/drm/radeon/radeon_atpx_handler.c | |||
@@ -166,6 +166,16 @@ out: | |||
166 | return err; | 166 | return err; |
167 | } | 167 | } |
168 | 168 | ||
169 | /** | ||
170 | * radeon_atpx_set_discrete_state - power up/down discrete GPU | ||
171 | * | ||
172 | * @atpx: atpx info struct | ||
173 | * @state: discrete GPU state (0 = power down, 1 = power up) | ||
174 | * | ||
175 | * Execute the ATPX_FUNCTION_POWER_CONTROL ATPX function to | ||
176 | * power down/up the discrete GPU (all asics). | ||
177 | * Returns 0 on success, error on failure. | ||
178 | */ | ||
169 | static int radeon_atpx_set_discrete_state(struct radeon_atpx *atpx, u8 state) | 179 | static int radeon_atpx_set_discrete_state(struct radeon_atpx *atpx, u8 state) |
170 | { | 180 | { |
171 | struct acpi_buffer params; | 181 | struct acpi_buffer params; |
@@ -187,6 +197,17 @@ static int radeon_atpx_set_discrete_state(struct radeon_atpx *atpx, u8 state) | |||
187 | return 0; | 197 | return 0; |
188 | } | 198 | } |
189 | 199 | ||
200 | /** | ||
201 | * radeon_atpx_switch_disp_mux - switch display mux | ||
202 | * | ||
203 | * @atpx: atpx info struct | ||
204 | * @mux_id: mux state (0 = integrated GPU, 1 = discrete GPU) | ||
205 | * | ||
206 | * Execute the ATPX_FUNCTION_DISPLAY_MUX_CONTROL ATPX function to | ||
207 | * switch the display mux between the discrete GPU and integrated GPU | ||
208 | * (all asics). | ||
209 | * Returns 0 on success, error on failure. | ||
210 | */ | ||
190 | static int radeon_atpx_switch_disp_mux(struct radeon_atpx *atpx, u16 mux_id) | 211 | static int radeon_atpx_switch_disp_mux(struct radeon_atpx *atpx, u16 mux_id) |
191 | { | 212 | { |
192 | struct acpi_buffer params; | 213 | struct acpi_buffer params; |
@@ -208,6 +229,17 @@ static int radeon_atpx_switch_disp_mux(struct radeon_atpx *atpx, u16 mux_id) | |||
208 | return 0; | 229 | return 0; |
209 | } | 230 | } |
210 | 231 | ||
232 | /** | ||
233 | * radeon_atpx_switch_i2c_mux - switch i2c/hpd mux | ||
234 | * | ||
235 | * @atpx: atpx info struct | ||
236 | * @mux_id: mux state (0 = integrated GPU, 1 = discrete GPU) | ||
237 | * | ||
238 | * Execute the ATPX_FUNCTION_I2C_MUX_CONTROL ATPX function to | ||
239 | * switch the i2c/hpd mux between the discrete GPU and integrated GPU | ||
240 | * (all asics). | ||
241 | * Returns 0 on success, error on failure. | ||
242 | */ | ||
211 | static int radeon_atpx_switch_i2c_mux(struct radeon_atpx *atpx, u16 mux_id) | 243 | static int radeon_atpx_switch_i2c_mux(struct radeon_atpx *atpx, u16 mux_id) |
212 | { | 244 | { |
213 | struct acpi_buffer params; | 245 | struct acpi_buffer params; |
@@ -229,6 +261,17 @@ static int radeon_atpx_switch_i2c_mux(struct radeon_atpx *atpx, u16 mux_id) | |||
229 | return 0; | 261 | return 0; |
230 | } | 262 | } |
231 | 263 | ||
264 | /** | ||
265 | * radeon_atpx_switch_start - notify the sbios of a GPU switch | ||
266 | * | ||
267 | * @atpx: atpx info struct | ||
268 | * @mux_id: mux state (0 = integrated GPU, 1 = discrete GPU) | ||
269 | * | ||
270 | * Execute the ATPX_FUNCTION_GRAPHICS_DEVICE_SWITCH_START_NOTIFICATION ATPX | ||
271 | * function to notify the sbios that a switch between the discrete GPU and | ||
272 | * integrated GPU has begun (all asics). | ||
273 | * Returns 0 on success, error on failure. | ||
274 | */ | ||
232 | static int radeon_atpx_switch_start(struct radeon_atpx *atpx, u16 mux_id) | 275 | static int radeon_atpx_switch_start(struct radeon_atpx *atpx, u16 mux_id) |
233 | { | 276 | { |
234 | struct acpi_buffer params; | 277 | struct acpi_buffer params; |
@@ -250,6 +293,17 @@ static int radeon_atpx_switch_start(struct radeon_atpx *atpx, u16 mux_id) | |||
250 | return 0; | 293 | return 0; |
251 | } | 294 | } |
252 | 295 | ||
296 | /** | ||
297 | * radeon_atpx_switch_end - notify the sbios of a GPU switch | ||
298 | * | ||
299 | * @atpx: atpx info struct | ||
300 | * @mux_id: mux state (0 = integrated GPU, 1 = discrete GPU) | ||
301 | * | ||
302 | * Execute the ATPX_FUNCTION_GRAPHICS_DEVICE_SWITCH_END_NOTIFICATION ATPX | ||
303 | * function to notify the sbios that a switch between the discrete GPU and | ||
304 | * integrated GPU has ended (all asics). | ||
305 | * Returns 0 on success, error on failure. | ||
306 | */ | ||
253 | static int radeon_atpx_switch_end(struct radeon_atpx *atpx, u16 mux_id) | 307 | static int radeon_atpx_switch_end(struct radeon_atpx *atpx, u16 mux_id) |
254 | { | 308 | { |
255 | struct acpi_buffer params; | 309 | struct acpi_buffer params; |
@@ -271,6 +325,15 @@ static int radeon_atpx_switch_end(struct radeon_atpx *atpx, u16 mux_id) | |||
271 | return 0; | 325 | return 0; |
272 | } | 326 | } |
273 | 327 | ||
328 | /** | ||
329 | * radeon_atpx_switchto - switch to the requested GPU | ||
330 | * | ||
331 | * @id: GPU to switch to | ||
332 | * | ||
333 | * Execute the necessary ATPX functions to switch between the discrete GPU and | ||
334 | * integrated GPU (all asics). | ||
335 | * Returns 0 on success, error on failure. | ||
336 | */ | ||
274 | static int radeon_atpx_switchto(enum vga_switcheroo_client_id id) | 337 | static int radeon_atpx_switchto(enum vga_switcheroo_client_id id) |
275 | { | 338 | { |
276 | u16 gpu_id; | 339 | u16 gpu_id; |
@@ -288,6 +351,16 @@ static int radeon_atpx_switchto(enum vga_switcheroo_client_id id) | |||
288 | return 0; | 351 | return 0; |
289 | } | 352 | } |
290 | 353 | ||
354 | /** | ||
355 | * radeon_atpx_switchto - switch to the requested GPU | ||
356 | * | ||
357 | * @id: GPU to switch to | ||
358 | * @state: requested power state (0 = off, 1 = on) | ||
359 | * | ||
360 | * Execute the necessary ATPX function to power down/up the discrete GPU | ||
361 | * (all asics). | ||
362 | * Returns 0 on success, error on failure. | ||
363 | */ | ||
291 | static int radeon_atpx_power_state(enum vga_switcheroo_client_id id, | 364 | static int radeon_atpx_power_state(enum vga_switcheroo_client_id id, |
292 | enum vga_switcheroo_state state) | 365 | enum vga_switcheroo_state state) |
293 | { | 366 | { |
@@ -299,6 +372,14 @@ static int radeon_atpx_power_state(enum vga_switcheroo_client_id id, | |||
299 | return 0; | 372 | return 0; |
300 | } | 373 | } |
301 | 374 | ||
375 | /** | ||
376 | * radeon_atpx_pci_probe_handle - look up the ATRM and ATPX handles | ||
377 | * | ||
378 | * @pdev: pci device | ||
379 | * | ||
380 | * Look up the ATPX and ATRM handles (all asics). | ||
381 | * Returns true if the handles are found, false if not. | ||
382 | */ | ||
302 | static bool radeon_atpx_pci_probe_handle(struct pci_dev *pdev) | 383 | static bool radeon_atpx_pci_probe_handle(struct pci_dev *pdev) |
303 | { | 384 | { |
304 | acpi_handle dhandle, atpx_handle; | 385 | acpi_handle dhandle, atpx_handle; |
@@ -317,12 +398,26 @@ static bool radeon_atpx_pci_probe_handle(struct pci_dev *pdev) | |||
317 | return true; | 398 | return true; |
318 | } | 399 | } |
319 | 400 | ||
401 | /** | ||
402 | * radeon_atpx_init - verify the ATPX interface | ||
403 | * | ||
404 | * Verify the ATPX interface (all asics). | ||
405 | * Returns 0 on success, error on failure. | ||
406 | */ | ||
320 | static int radeon_atpx_init(void) | 407 | static int radeon_atpx_init(void) |
321 | { | 408 | { |
322 | /* set up the ATPX handle */ | 409 | /* set up the ATPX handle */ |
323 | return radeon_atpx_verify_interface(&radeon_atpx_priv.atpx); | 410 | return radeon_atpx_verify_interface(&radeon_atpx_priv.atpx); |
324 | } | 411 | } |
325 | 412 | ||
413 | /** | ||
414 | * radeon_atpx_get_client_id - get the client id | ||
415 | * | ||
416 | * @pdev: pci device | ||
417 | * | ||
418 | * look up whether we are the integrated or discrete GPU (all asics). | ||
419 | * Returns the client id. | ||
420 | */ | ||
326 | static int radeon_atpx_get_client_id(struct pci_dev *pdev) | 421 | static int radeon_atpx_get_client_id(struct pci_dev *pdev) |
327 | { | 422 | { |
328 | if (radeon_atpx_priv.dhandle == DEVICE_ACPI_HANDLE(&pdev->dev)) | 423 | if (radeon_atpx_priv.dhandle == DEVICE_ACPI_HANDLE(&pdev->dev)) |
@@ -338,6 +433,12 @@ static struct vga_switcheroo_handler radeon_atpx_handler = { | |||
338 | .get_client_id = radeon_atpx_get_client_id, | 433 | .get_client_id = radeon_atpx_get_client_id, |
339 | }; | 434 | }; |
340 | 435 | ||
436 | /** | ||
437 | * radeon_atpx_detect - detect whether we have PX | ||
438 | * | ||
439 | * Check if we have a PX system (all asics). | ||
440 | * Returns true if we have a PX system, false if not. | ||
441 | */ | ||
341 | static bool radeon_atpx_detect(void) | 442 | static bool radeon_atpx_detect(void) |
342 | { | 443 | { |
343 | char acpi_method_name[255] = { 0 }; | 444 | char acpi_method_name[255] = { 0 }; |
@@ -362,6 +463,11 @@ static bool radeon_atpx_detect(void) | |||
362 | return false; | 463 | return false; |
363 | } | 464 | } |
364 | 465 | ||
466 | /** | ||
467 | * radeon_register_atpx_handler - register with vga_switcheroo | ||
468 | * | ||
469 | * Register the PX callbacks with vga_switcheroo (all asics). | ||
470 | */ | ||
365 | void radeon_register_atpx_handler(void) | 471 | void radeon_register_atpx_handler(void) |
366 | { | 472 | { |
367 | bool r; | 473 | bool r; |
@@ -374,6 +480,11 @@ void radeon_register_atpx_handler(void) | |||
374 | vga_switcheroo_register_handler(&radeon_atpx_handler); | 480 | vga_switcheroo_register_handler(&radeon_atpx_handler); |
375 | } | 481 | } |
376 | 482 | ||
483 | /** | ||
484 | * radeon_unregister_atpx_handler - unregister with vga_switcheroo | ||
485 | * | ||
486 | * Unregister the PX callbacks with vga_switcheroo (all asics). | ||
487 | */ | ||
377 | void radeon_unregister_atpx_handler(void) | 488 | void radeon_unregister_atpx_handler(void) |
378 | { | 489 | { |
379 | vga_switcheroo_unregister_handler(); | 490 | vga_switcheroo_unregister_handler(); |