LUT updates
[platform/upstream/libdrm.git] / shared-core / radeon_ms_properties.c
1 /*
2  * Copyright 2007 Jérôme Glisse
3  * All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19  * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 /*
25  * Authors:
26  *    Jerome Glisse <glisse@freedesktop.org>
27  */
28 #include "drmP.h"
29 #include "drm.h"
30 #include "radeon_ms.h"
31
32 struct radeon_ms_output radeon_ms_dac1 = {
33         OUTPUT_DAC1,
34         NULL,
35         NULL,
36         radeon_ms_dac1_initialize,
37         radeon_ms_dac1_detect,
38         radeon_ms_dac1_dpms,
39         radeon_ms_dac1_get_modes,
40         radeon_ms_dac1_mode_fixup,
41         radeon_ms_dac1_mode_set,
42         radeon_ms_dac1_restore,
43         radeon_ms_dac1_save
44 };
45
46 struct radeon_ms_output radeon_ms_dac2 = {
47         OUTPUT_DAC2,
48         NULL,
49         NULL,
50         radeon_ms_dac2_initialize,
51         radeon_ms_dac2_detect,
52         radeon_ms_dac2_dpms,
53         radeon_ms_dac2_get_modes,
54         radeon_ms_dac2_mode_fixup,
55         radeon_ms_dac2_mode_set,
56         radeon_ms_dac2_restore,
57         radeon_ms_dac2_save
58 };
59
60 struct radeon_ms_connector radeon_ms_vga = {
61         NULL, NULL, NULL, CONNECTOR_VGA, MT_NONE, 0, GPIO_DDC1,
62         {
63                 0, -1, -1, -1, -1, -1, -1, -1
64         },
65         "VGA"
66 };
67
68 struct radeon_ms_connector radeon_ms_dvi_i_2 = {
69         NULL, NULL, NULL, CONNECTOR_DVI_I, MT_NONE, 0, GPIO_DDC2,
70         {
71                 1, -1, -1, -1, -1, -1, -1, -1
72         },
73         "DVI-I"
74 };
75
76 struct radeon_ms_properties properties[] = {
77         /* default only one VGA connector */
78         {
79                 0, 0, 27000, 12, 25000, 200000, 1, 1, 1, 1,
80                 {
81                         &radeon_ms_dac1, NULL, NULL, NULL, NULL, NULL, NULL,
82                         NULL
83                 },
84                 {
85                         &radeon_ms_vga, NULL, NULL, NULL, NULL, NULL, NULL,
86                         NULL
87                 }
88         }
89 };
90
91 int radeon_ms_properties_init(struct drm_device *dev)
92 {
93         struct drm_radeon_private *dev_priv = dev->dev_private;
94         int i, ret;
95
96         for (i = 1; i < sizeof(properties)/sizeof(properties[0]); i++) {
97                 if (dev->pdev->subsystem_vendor == properties[i].subvendor &&
98                     dev->pdev->subsystem_device == properties[i].subdevice) {
99                         DRM_INFO("[radeon_ms] found properties for "
100                                  "0x%04X:0x%04X\n", properties[i].subvendor,
101                                  properties[i].subdevice);
102                         memcpy(&dev_priv->properties, &properties[i],
103                                sizeof(struct radeon_ms_properties));
104                 }
105         }
106         if (dev_priv->properties.subvendor == 0) {
107                 ret = radeon_ms_rom_get_properties(dev);
108                 if (ret < 0) {
109                         return ret;
110                 }
111                 if (!ret) {
112                         memcpy(&dev_priv->properties, &properties[0],
113                                sizeof(struct radeon_ms_properties));
114                 } else {
115                         dev_priv->properties.pll_dummy_reads = 1;
116                         dev_priv->properties.pll_delay = 1;
117                         dev_priv->properties.pll_r300_errata = 1;
118                 }
119                 dev_priv->properties.subvendor = dev->pdev->subsystem_vendor;
120                 dev_priv->properties.subdevice = dev->pdev->subsystem_device;
121         }
122         return 0;
123 }