]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/gpu/drm/amd/include/cgs_common.h
drm/amdgpu: add new cgs interface to get display info (v2)
[karo-tx-linux.git] / drivers / gpu / drm / amd / include / cgs_common.h
1 /*
2  * Copyright 2015 Advanced Micro Devices, Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20  * OTHER DEALINGS IN THE SOFTWARE.
21  *
22  *
23  */
24 #ifndef _CGS_COMMON_H
25 #define _CGS_COMMON_H
26
27 #include "amd_shared.h"
28
29 /**
30  * enum cgs_gpu_mem_type - GPU memory types
31  */
32 enum cgs_gpu_mem_type {
33         CGS_GPU_MEM_TYPE__VISIBLE_FB,
34         CGS_GPU_MEM_TYPE__INVISIBLE_FB,
35         CGS_GPU_MEM_TYPE__VISIBLE_CONTIG_FB,
36         CGS_GPU_MEM_TYPE__INVISIBLE_CONTIG_FB,
37         CGS_GPU_MEM_TYPE__GART_CACHEABLE,
38         CGS_GPU_MEM_TYPE__GART_WRITECOMBINE
39 };
40
41 /**
42  * enum cgs_ind_reg - Indirect register spaces
43  */
44 enum cgs_ind_reg {
45         CGS_IND_REG__MMIO,
46         CGS_IND_REG__PCIE,
47         CGS_IND_REG__SMC,
48         CGS_IND_REG__UVD_CTX,
49         CGS_IND_REG__DIDT,
50         CGS_IND_REG__AUDIO_ENDPT
51 };
52
53 /**
54  * enum cgs_clock - Clocks controlled by the SMU
55  */
56 enum cgs_clock {
57         CGS_CLOCK__SCLK,
58         CGS_CLOCK__MCLK,
59         CGS_CLOCK__VCLK,
60         CGS_CLOCK__DCLK,
61         CGS_CLOCK__ECLK,
62         CGS_CLOCK__ACLK,
63         CGS_CLOCK__ICLK,
64         /* ... */
65 };
66
67 /**
68  * enum cgs_engine - Engines that can be statically power-gated
69  */
70 enum cgs_engine {
71         CGS_ENGINE__UVD,
72         CGS_ENGINE__VCE,
73         CGS_ENGINE__VP8,
74         CGS_ENGINE__ACP_DMA,
75         CGS_ENGINE__ACP_DSP0,
76         CGS_ENGINE__ACP_DSP1,
77         CGS_ENGINE__ISP,
78         /* ... */
79 };
80
81 /**
82  * enum cgs_voltage_planes - Voltage planes for external camera HW
83  */
84 enum cgs_voltage_planes {
85         CGS_VOLTAGE_PLANE__SENSOR0,
86         CGS_VOLTAGE_PLANE__SENSOR1,
87         /* ... */
88 };
89
90 /*
91  * enum cgs_ucode_id - Firmware types for different IPs
92  */
93 enum cgs_ucode_id {
94         CGS_UCODE_ID_SMU = 0,
95         CGS_UCODE_ID_SDMA0,
96         CGS_UCODE_ID_SDMA1,
97         CGS_UCODE_ID_CP_CE,
98         CGS_UCODE_ID_CP_PFP,
99         CGS_UCODE_ID_CP_ME,
100         CGS_UCODE_ID_CP_MEC,
101         CGS_UCODE_ID_CP_MEC_JT1,
102         CGS_UCODE_ID_CP_MEC_JT2,
103         CGS_UCODE_ID_GMCON_RENG,
104         CGS_UCODE_ID_RLC_G,
105         CGS_UCODE_ID_MAXIMUM,
106 };
107
108 enum cgs_system_info_id {
109         CGS_SYSTEM_INFO_ADAPTER_BDF_ID = 1,
110         CGS_SYSTEM_INFO_ID_MAXIMUM,
111 };
112
113 struct cgs_system_info {
114         uint64_t       size;
115         uint64_t       info_id;
116         union {
117                 void           *ptr;
118                 uint64_t        value;
119         };
120         uint64_t               padding[13];
121 };
122
123 /**
124  * struct cgs_clock_limits - Clock limits
125  *
126  * Clocks are specified in 10KHz units.
127  */
128 struct cgs_clock_limits {
129         unsigned min;           /**< Minimum supported frequency */
130         unsigned max;           /**< Maxumim supported frequency */
131         unsigned sustainable;   /**< Thermally sustainable frequency */
132 };
133
134 /**
135  * struct cgs_firmware_info - Firmware information
136  */
137 struct cgs_firmware_info {
138         uint16_t                version;
139         uint16_t                feature_version;
140         uint32_t                image_size;
141         uint64_t                mc_addr;
142         void                    *kptr;
143 };
144
145 struct cgs_mode_info {
146         uint32_t                refresh_rate;
147         uint32_t                ref_clock;
148         uint32_t                vblank_time_us;
149 };
150
151 struct cgs_display_info {
152         uint32_t                display_count;
153         uint32_t                active_display_mask;
154         struct cgs_mode_info *mode_info;
155 };
156
157 typedef unsigned long cgs_handle_t;
158
159 #define CGS_ACPI_METHOD_ATCS          0x53435441
160 #define CGS_ACPI_METHOD_ATIF          0x46495441
161 #define CGS_ACPI_METHOD_ATPX          0x58505441
162 #define CGS_ACPI_FIELD_METHOD_NAME                      0x00000001
163 #define CGS_ACPI_FIELD_INPUT_ARGUMENT_COUNT             0x00000002
164 #define CGS_ACPI_MAX_BUFFER_SIZE     256
165 #define CGS_ACPI_TYPE_ANY                      0x00
166 #define CGS_ACPI_TYPE_INTEGER               0x01
167 #define CGS_ACPI_TYPE_STRING                0x02
168 #define CGS_ACPI_TYPE_BUFFER                0x03
169 #define CGS_ACPI_TYPE_PACKAGE               0x04
170
171 struct cgs_acpi_method_argument {
172         uint32_t type;
173         uint32_t method_length;
174         uint32_t data_length;
175         union{
176                 uint32_t value;
177                 void *pointer;
178         };
179 };
180
181 struct cgs_acpi_method_info {
182         uint32_t size;
183         uint32_t field;
184         uint32_t input_count;
185         uint32_t name;
186         struct cgs_acpi_method_argument *pinput_argument;
187         uint32_t output_count;
188         struct cgs_acpi_method_argument *poutput_argument;
189         uint32_t padding[9];
190 };
191
192 /**
193  * cgs_gpu_mem_info() - Return information about memory heaps
194  * @cgs_device: opaque device handle
195  * @type:       memory type
196  * @mc_start:   Start MC address of the heap (output)
197  * @mc_size:    MC address space size (output)
198  * @mem_size:   maximum amount of memory available for allocation (output)
199  *
200  * This function returns information about memory heaps. The type
201  * parameter is used to select the memory heap. The mc_start and
202  * mc_size for GART heaps may be bigger than the memory available for
203  * allocation.
204  *
205  * mc_start and mc_size are undefined for non-contiguous FB memory
206  * types, since buffers allocated with these types may or may not be
207  * GART mapped.
208  *
209  * Return:  0 on success, -errno otherwise
210  */
211 typedef int (*cgs_gpu_mem_info_t)(void *cgs_device, enum cgs_gpu_mem_type type,
212                                   uint64_t *mc_start, uint64_t *mc_size,
213                                   uint64_t *mem_size);
214
215 /**
216  * cgs_gmap_kmem() - map kernel memory to GART aperture
217  * @cgs_device: opaque device handle
218  * @kmem:       pointer to kernel memory
219  * @size:       size to map
220  * @min_offset: minimum offset from start of GART aperture
221  * @max_offset: maximum offset from start of GART aperture
222  * @kmem_handle: kernel memory handle (output)
223  * @mcaddr:     MC address (output)
224  *
225  * Return:  0 on success, -errno otherwise
226  */
227 typedef int (*cgs_gmap_kmem_t)(void *cgs_device, void *kmem, uint64_t size,
228                                uint64_t min_offset, uint64_t max_offset,
229                                cgs_handle_t *kmem_handle, uint64_t *mcaddr);
230
231 /**
232  * cgs_gunmap_kmem() - unmap kernel memory
233  * @cgs_device: opaque device handle
234  * @kmem_handle: kernel memory handle returned by gmap_kmem
235  *
236  * Return:  0 on success, -errno otherwise
237  */
238 typedef int (*cgs_gunmap_kmem_t)(void *cgs_device, cgs_handle_t kmem_handle);
239
240 /**
241  * cgs_alloc_gpu_mem() - Allocate GPU memory
242  * @cgs_device: opaque device handle
243  * @type:       memory type
244  * @size:       size in bytes
245  * @align:      alignment in bytes
246  * @min_offset: minimum offset from start of heap
247  * @max_offset: maximum offset from start of heap
248  * @handle:     memory handle (output)
249  *
250  * The memory types CGS_GPU_MEM_TYPE_*_CONTIG_FB force contiguous
251  * memory allocation. This guarantees that the MC address returned by
252  * cgs_gmap_gpu_mem is not mapped through the GART. The non-contiguous
253  * FB memory types may be GART mapped depending on memory
254  * fragmentation and memory allocator policies.
255  *
256  * If min/max_offset are non-0, the allocation will be forced to
257  * reside between these offsets in its respective memory heap. The
258  * base address that the offset relates to, depends on the memory
259  * type.
260  *
261  * - CGS_GPU_MEM_TYPE__*_CONTIG_FB: FB MC base address
262  * - CGS_GPU_MEM_TYPE__GART_*:      GART aperture base address
263  * - others:                        undefined, don't use with max_offset
264  *
265  * Return:  0 on success, -errno otherwise
266  */
267 typedef int (*cgs_alloc_gpu_mem_t)(void *cgs_device, enum cgs_gpu_mem_type type,
268                                    uint64_t size, uint64_t align,
269                                    uint64_t min_offset, uint64_t max_offset,
270                                    cgs_handle_t *handle);
271
272 /**
273  * cgs_free_gpu_mem() - Free GPU memory
274  * @cgs_device: opaque device handle
275  * @handle:     memory handle returned by alloc or import
276  *
277  * Return:  0 on success, -errno otherwise
278  */
279 typedef int (*cgs_free_gpu_mem_t)(void *cgs_device, cgs_handle_t handle);
280
281 /**
282  * cgs_gmap_gpu_mem() - GPU-map GPU memory
283  * @cgs_device: opaque device handle
284  * @handle:     memory handle returned by alloc or import
285  * @mcaddr:     MC address (output)
286  *
287  * Ensures that a buffer is GPU accessible and returns its MC address.
288  *
289  * Return:  0 on success, -errno otherwise
290  */
291 typedef int (*cgs_gmap_gpu_mem_t)(void *cgs_device, cgs_handle_t handle,
292                                   uint64_t *mcaddr);
293
294 /**
295  * cgs_gunmap_gpu_mem() - GPU-unmap GPU memory
296  * @cgs_device: opaque device handle
297  * @handle:     memory handle returned by alloc or import
298  *
299  * Allows the buffer to be migrated while it's not used by the GPU.
300  *
301  * Return:  0 on success, -errno otherwise
302  */
303 typedef int (*cgs_gunmap_gpu_mem_t)(void *cgs_device, cgs_handle_t handle);
304
305 /**
306  * cgs_kmap_gpu_mem() - Kernel-map GPU memory
307  *
308  * @cgs_device: opaque device handle
309  * @handle:     memory handle returned by alloc or import
310  * @map:        Kernel virtual address the memory was mapped to (output)
311  *
312  * Return:  0 on success, -errno otherwise
313  */
314 typedef int (*cgs_kmap_gpu_mem_t)(void *cgs_device, cgs_handle_t handle,
315                                   void **map);
316
317 /**
318  * cgs_kunmap_gpu_mem() - Kernel-unmap GPU memory
319  * @cgs_device: opaque device handle
320  * @handle:     memory handle returned by alloc or import
321  *
322  * Return:  0 on success, -errno otherwise
323  */
324 typedef int (*cgs_kunmap_gpu_mem_t)(void *cgs_device, cgs_handle_t handle);
325
326 /**
327  * cgs_read_register() - Read an MMIO register
328  * @cgs_device: opaque device handle
329  * @offset:     register offset
330  *
331  * Return:  register value
332  */
333 typedef uint32_t (*cgs_read_register_t)(void *cgs_device, unsigned offset);
334
335 /**
336  * cgs_write_register() - Write an MMIO register
337  * @cgs_device: opaque device handle
338  * @offset:     register offset
339  * @value:      register value
340  */
341 typedef void (*cgs_write_register_t)(void *cgs_device, unsigned offset,
342                                      uint32_t value);
343
344 /**
345  * cgs_read_ind_register() - Read an indirect register
346  * @cgs_device: opaque device handle
347  * @offset:     register offset
348  *
349  * Return:  register value
350  */
351 typedef uint32_t (*cgs_read_ind_register_t)(void *cgs_device, enum cgs_ind_reg space,
352                                             unsigned index);
353
354 /**
355  * cgs_write_ind_register() - Write an indirect register
356  * @cgs_device: opaque device handle
357  * @offset:     register offset
358  * @value:      register value
359  */
360 typedef void (*cgs_write_ind_register_t)(void *cgs_device, enum cgs_ind_reg space,
361                                          unsigned index, uint32_t value);
362
363 /**
364  * cgs_read_pci_config_byte() - Read byte from PCI configuration space
365  * @cgs_device: opaque device handle
366  * @addr:       address
367  *
368  * Return:  Value read
369  */
370 typedef uint8_t (*cgs_read_pci_config_byte_t)(void *cgs_device, unsigned addr);
371
372 /**
373  * cgs_read_pci_config_word() - Read word from PCI configuration space
374  * @cgs_device: opaque device handle
375  * @addr:       address, must be word-aligned
376  *
377  * Return:  Value read
378  */
379 typedef uint16_t (*cgs_read_pci_config_word_t)(void *cgs_device, unsigned addr);
380
381 /**
382  * cgs_read_pci_config_dword() - Read dword from PCI configuration space
383  * @cgs_device: opaque device handle
384  * @addr:       address, must be dword-aligned
385  *
386  * Return:  Value read
387  */
388 typedef uint32_t (*cgs_read_pci_config_dword_t)(void *cgs_device,
389                                                 unsigned addr);
390
391 /**
392  * cgs_write_pci_config_byte() - Write byte to PCI configuration space
393  * @cgs_device: opaque device handle
394  * @addr:       address
395  * @value:      value to write
396  */
397 typedef void (*cgs_write_pci_config_byte_t)(void *cgs_device, unsigned addr,
398                                             uint8_t value);
399
400 /**
401  * cgs_write_pci_config_word() - Write byte to PCI configuration space
402  * @cgs_device: opaque device handle
403  * @addr:       address, must be word-aligned
404  * @value:      value to write
405  */
406 typedef void (*cgs_write_pci_config_word_t)(void *cgs_device, unsigned addr,
407                                             uint16_t value);
408
409 /**
410  * cgs_write_pci_config_dword() - Write byte to PCI configuration space
411  * @cgs_device: opaque device handle
412  * @addr:       address, must be dword-aligned
413  * @value:      value to write
414  */
415 typedef void (*cgs_write_pci_config_dword_t)(void *cgs_device, unsigned addr,
416                                              uint32_t value);
417
418 /**
419  * cgs_atom_get_data_table() - Get a pointer to an ATOM BIOS data table
420  * @cgs_device: opaque device handle
421  * @table:      data table index
422  * @size:       size of the table (output, may be NULL)
423  * @frev:       table format revision (output, may be NULL)
424  * @crev:       table content revision (output, may be NULL)
425  *
426  * Return: Pointer to start of the table, or NULL on failure
427  */
428 typedef const void *(*cgs_atom_get_data_table_t)(
429         void *cgs_device, unsigned table,
430         uint16_t *size, uint8_t *frev, uint8_t *crev);
431
432 /**
433  * cgs_atom_get_cmd_table_revs() - Get ATOM BIOS command table revisions
434  * @cgs_device: opaque device handle
435  * @table:      data table index
436  * @frev:       table format revision (output, may be NULL)
437  * @crev:       table content revision (output, may be NULL)
438  *
439  * Return: 0 on success, -errno otherwise
440  */
441 typedef int (*cgs_atom_get_cmd_table_revs_t)(void *cgs_device, unsigned table,
442                                              uint8_t *frev, uint8_t *crev);
443
444 /**
445  * cgs_atom_exec_cmd_table() - Execute an ATOM BIOS command table
446  * @cgs_device: opaque device handle
447  * @table:      command table index
448  * @args:       arguments
449  *
450  * Return: 0 on success, -errno otherwise
451  */
452 typedef int (*cgs_atom_exec_cmd_table_t)(void *cgs_device,
453                                          unsigned table, void *args);
454
455 /**
456  * cgs_create_pm_request() - Create a power management request
457  * @cgs_device: opaque device handle
458  * @request:    handle of created PM request (output)
459  *
460  * Return:  0 on success, -errno otherwise
461  */
462 typedef int (*cgs_create_pm_request_t)(void *cgs_device, cgs_handle_t *request);
463
464 /**
465  * cgs_destroy_pm_request() - Destroy a power management request
466  * @cgs_device: opaque device handle
467  * @request:    handle of created PM request
468  *
469  * Return:  0 on success, -errno otherwise
470  */
471 typedef int (*cgs_destroy_pm_request_t)(void *cgs_device, cgs_handle_t request);
472
473 /**
474  * cgs_set_pm_request() - Activate or deactiveate a PM request
475  * @cgs_device: opaque device handle
476  * @request:    PM request handle
477  * @active:     0 = deactivate, non-0 = activate
478  *
479  * While a PM request is active, its minimum clock requests are taken
480  * into account as the requested engines are powered up. When the
481  * request is inactive, the engines may be powered down and clocks may
482  * be lower, depending on other PM requests by other driver
483  * components.
484  *
485  * Return:  0 on success, -errno otherwise
486  */
487 typedef int (*cgs_set_pm_request_t)(void *cgs_device, cgs_handle_t request,
488                                     int active);
489
490 /**
491  * cgs_pm_request_clock() - Request a minimum frequency for a specific clock
492  * @cgs_device: opaque device handle
493  * @request:    PM request handle
494  * @clock:      which clock?
495  * @freq:       requested min. frequency in 10KHz units (0 to clear request)
496  *
497  * Return:  0 on success, -errno otherwise
498  */
499 typedef int (*cgs_pm_request_clock_t)(void *cgs_device, cgs_handle_t request,
500                                       enum cgs_clock clock, unsigned freq);
501
502 /**
503  * cgs_pm_request_engine() - Request an engine to be powered up
504  * @cgs_device: opaque device handle
505  * @request:    PM request handle
506  * @engine:     which engine?
507  * @powered:    0 = powered down, non-0 = powered up
508  *
509  * Return:  0 on success, -errno otherwise
510  */
511 typedef int (*cgs_pm_request_engine_t)(void *cgs_device, cgs_handle_t request,
512                                        enum cgs_engine engine, int powered);
513
514 /**
515  * cgs_pm_query_clock_limits() - Query clock frequency limits
516  * @cgs_device: opaque device handle
517  * @clock:      which clock?
518  * @limits:     clock limits
519  *
520  * Return:  0 on success, -errno otherwise
521  */
522 typedef int (*cgs_pm_query_clock_limits_t)(void *cgs_device,
523                                            enum cgs_clock clock,
524                                            struct cgs_clock_limits *limits);
525
526 /**
527  * cgs_set_camera_voltages() - Apply specific voltages to PMIC voltage planes
528  * @cgs_device: opaque device handle
529  * @mask:       bitmask of voltages to change (1<<CGS_VOLTAGE_PLANE__xyz|...)
530  * @voltages:   pointer to array of voltage values in 1mV units
531  *
532  * Return: 0 on success, -errno otherwise
533  */
534 typedef int (*cgs_set_camera_voltages_t)(void *cgs_device, uint32_t mask,
535                                          const uint32_t *voltages);
536 /**
537  * cgs_get_firmware_info - Get the firmware information from core driver
538  * @cgs_device: opaque device handle
539  * @type: the firmware type
540  * @info: returend firmware information
541  *
542  * Return: 0 on success, -errno otherwise
543  */
544 typedef int (*cgs_get_firmware_info)(void *cgs_device,
545                                      enum cgs_ucode_id type,
546                                      struct cgs_firmware_info *info);
547
548 typedef int(*cgs_set_powergating_state)(void *cgs_device,
549                                   enum amd_ip_block_type block_type,
550                                   enum amd_powergating_state state);
551
552 typedef int(*cgs_set_clockgating_state)(void *cgs_device,
553                                   enum amd_ip_block_type block_type,
554                                   enum amd_clockgating_state state);
555
556 typedef int(*cgs_get_active_displays_info)(
557                                         void *cgs_device,
558                                         struct cgs_display_info *info);
559
560 typedef int (*cgs_call_acpi_method)(void *cgs_device,
561                                         uint32_t acpi_method,
562                                         uint32_t acpi_function,
563                                         void *pinput, void *poutput,
564                                         uint32_t output_count,
565                                         uint32_t input_size,
566                                         uint32_t output_size);
567
568 typedef int (*cgs_query_system_info)(void *cgs_device,
569                                 struct cgs_system_info *sys_info);
570
571 struct cgs_ops {
572         /* memory management calls (similar to KFD interface) */
573         cgs_gpu_mem_info_t gpu_mem_info;
574         cgs_gmap_kmem_t gmap_kmem;
575         cgs_gunmap_kmem_t gunmap_kmem;
576         cgs_alloc_gpu_mem_t alloc_gpu_mem;
577         cgs_free_gpu_mem_t free_gpu_mem;
578         cgs_gmap_gpu_mem_t gmap_gpu_mem;
579         cgs_gunmap_gpu_mem_t gunmap_gpu_mem;
580         cgs_kmap_gpu_mem_t kmap_gpu_mem;
581         cgs_kunmap_gpu_mem_t kunmap_gpu_mem;
582         /* MMIO access */
583         cgs_read_register_t read_register;
584         cgs_write_register_t write_register;
585         cgs_read_ind_register_t read_ind_register;
586         cgs_write_ind_register_t write_ind_register;
587         /* PCI configuration space access */
588         cgs_read_pci_config_byte_t read_pci_config_byte;
589         cgs_read_pci_config_word_t read_pci_config_word;
590         cgs_read_pci_config_dword_t read_pci_config_dword;
591         cgs_write_pci_config_byte_t write_pci_config_byte;
592         cgs_write_pci_config_word_t write_pci_config_word;
593         cgs_write_pci_config_dword_t write_pci_config_dword;
594         /* ATOM BIOS */
595         cgs_atom_get_data_table_t atom_get_data_table;
596         cgs_atom_get_cmd_table_revs_t atom_get_cmd_table_revs;
597         cgs_atom_exec_cmd_table_t atom_exec_cmd_table;
598         /* Power management */
599         cgs_create_pm_request_t create_pm_request;
600         cgs_destroy_pm_request_t destroy_pm_request;
601         cgs_set_pm_request_t set_pm_request;
602         cgs_pm_request_clock_t pm_request_clock;
603         cgs_pm_request_engine_t pm_request_engine;
604         cgs_pm_query_clock_limits_t pm_query_clock_limits;
605         cgs_set_camera_voltages_t set_camera_voltages;
606         /* Firmware Info */
607         cgs_get_firmware_info get_firmware_info;
608         /* cg pg interface*/
609         cgs_set_powergating_state set_powergating_state;
610         cgs_set_clockgating_state set_clockgating_state;
611         /* display manager */
612         cgs_get_active_displays_info get_active_displays_info;
613         /* ACPI */
614         cgs_call_acpi_method call_acpi_method;
615         /* get system info */
616         cgs_query_system_info query_system_info;
617 };
618
619 struct cgs_os_ops; /* To be define in OS-specific CGS header */
620
621 struct cgs_device
622 {
623         const struct cgs_ops *ops;
624         const struct cgs_os_ops *os_ops;
625         /* to be embedded at the start of driver private structure */
626 };
627
628 /* Convenience macros that make CGS indirect function calls look like
629  * normal function calls */
630 #define CGS_CALL(func,dev,...) \
631         (((struct cgs_device *)dev)->ops->func(dev, ##__VA_ARGS__))
632 #define CGS_OS_CALL(func,dev,...) \
633         (((struct cgs_device *)dev)->os_ops->func(dev, ##__VA_ARGS__))
634
635 #define cgs_gpu_mem_info(dev,type,mc_start,mc_size,mem_size)            \
636         CGS_CALL(gpu_mem_info,dev,type,mc_start,mc_size,mem_size)
637 #define cgs_gmap_kmem(dev,kmem,size,min_off,max_off,kmem_handle,mcaddr) \
638         CGS_CALL(gmap_kmem,dev,kmem,size,min_off,max_off,kmem_handle,mcaddr)
639 #define cgs_gunmap_kmem(dev,kmem_handle)        \
640         CGS_CALL(gunmap_kmem,dev,keme_handle)
641 #define cgs_alloc_gpu_mem(dev,type,size,align,min_off,max_off,handle)   \
642         CGS_CALL(alloc_gpu_mem,dev,type,size,align,min_off,max_off,handle)
643 #define cgs_free_gpu_mem(dev,handle)            \
644         CGS_CALL(free_gpu_mem,dev,handle)
645 #define cgs_gmap_gpu_mem(dev,handle,mcaddr)     \
646         CGS_CALL(gmap_gpu_mem,dev,handle,mcaddr)
647 #define cgs_gunmap_gpu_mem(dev,handle)          \
648         CGS_CALL(gunmap_gpu_mem,dev,handle)
649 #define cgs_kmap_gpu_mem(dev,handle,map)        \
650         CGS_CALL(kmap_gpu_mem,dev,handle,map)
651 #define cgs_kunmap_gpu_mem(dev,handle)          \
652         CGS_CALL(kunmap_gpu_mem,dev,handle)
653
654 #define cgs_read_register(dev,offset)           \
655         CGS_CALL(read_register,dev,offset)
656 #define cgs_write_register(dev,offset,value)            \
657         CGS_CALL(write_register,dev,offset,value)
658 #define cgs_read_ind_register(dev,space,index)          \
659         CGS_CALL(read_ind_register,dev,space,index)
660 #define cgs_write_ind_register(dev,space,index,value)           \
661         CGS_CALL(write_ind_register,dev,space,index,value)
662
663 #define cgs_read_pci_config_byte(dev,addr)      \
664         CGS_CALL(read_pci_config_byte,dev,addr)
665 #define cgs_read_pci_config_word(dev,addr)      \
666         CGS_CALL(read_pci_config_word,dev,addr)
667 #define cgs_read_pci_config_dword(dev,addr)             \
668         CGS_CALL(read_pci_config_dword,dev,addr)
669 #define cgs_write_pci_config_byte(dev,addr,value)       \
670         CGS_CALL(write_pci_config_byte,dev,addr,value)
671 #define cgs_write_pci_config_word(dev,addr,value)       \
672         CGS_CALL(write_pci_config_word,dev,addr,value)
673 #define cgs_write_pci_config_dword(dev,addr,value)      \
674         CGS_CALL(write_pci_config_dword,dev,addr,value)
675
676 #define cgs_atom_get_data_table(dev,table,size,frev,crev)       \
677         CGS_CALL(atom_get_data_table,dev,table,size,frev,crev)
678 #define cgs_atom_get_cmd_table_revs(dev,table,frev,crev)        \
679         CGS_CALL(atom_get_cmd_table_revs,dev,table,frev,crev)
680 #define cgs_atom_exec_cmd_table(dev,table,args)         \
681         CGS_CALL(atom_exec_cmd_table,dev,table,args)
682
683 #define cgs_create_pm_request(dev,request)      \
684         CGS_CALL(create_pm_request,dev,request)
685 #define cgs_destroy_pm_request(dev,request)             \
686         CGS_CALL(destroy_pm_request,dev,request)
687 #define cgs_set_pm_request(dev,request,active)          \
688         CGS_CALL(set_pm_request,dev,request,active)
689 #define cgs_pm_request_clock(dev,request,clock,freq)            \
690         CGS_CALL(pm_request_clock,dev,request,clock,freq)
691 #define cgs_pm_request_engine(dev,request,engine,powered)       \
692         CGS_CALL(pm_request_engine,dev,request,engine,powered)
693 #define cgs_pm_query_clock_limits(dev,clock,limits)             \
694         CGS_CALL(pm_query_clock_limits,dev,clock,limits)
695 #define cgs_set_camera_voltages(dev,mask,voltages)      \
696         CGS_CALL(set_camera_voltages,dev,mask,voltages)
697 #define cgs_get_firmware_info(dev, type, info)  \
698         CGS_CALL(get_firmware_info, dev, type, info)
699 #define cgs_set_powergating_state(dev, block_type, state)       \
700         CGS_CALL(set_powergating_state, dev, block_type, state)
701 #define cgs_set_clockgating_state(dev, block_type, state)       \
702         CGS_CALL(set_clockgating_state, dev, block_type, state)
703 #define cgs_get_active_displays_info(dev, info) \
704         CGS_CALL(get_active_displays_info, dev, info)
705 #define cgs_call_acpi_method(dev, acpi_method, acpi_function, pintput, poutput, output_count, input_size, output_size)  \
706         CGS_CALL(call_acpi_method, dev, acpi_method, acpi_function, pintput, poutput, output_count, input_size, output_size)
707 #define cgs_query_system_info(dev, sys_info)    \
708         CGS_CALL(query_system_info, dev, sys_info)
709
710 #endif /* _CGS_COMMON_H */