summaryrefslogtreecommitdiff
path: root/src/lib/ecore_drm/ecore_drm_device.c
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2014-09-23 13:13:25 -0400
committerChris Michael <cp.michael@samsung.com>2014-09-23 15:31:12 -0400
commitf16e061685deed0b244d81b604ac7384d534658c (patch)
tree951bdec8a6dd266603f98bdc5c7480bdf2fa697c /src/lib/ecore_drm/ecore_drm_device.c
parent16d8352ebef8dedb41dc4a31fa14f7ccf9a5bb90 (diff)
ecore-drm: Fix ecore_drm_device_find function to use Eeze
Summary: This converts the internal code of ecore_drm_device_find function to use Eeze function calls instead of udev in order to locate the drm card. @fix Signed-off-by: Chris Michael <cp.michael@samsung.com>
Diffstat (limited to 'src/lib/ecore_drm/ecore_drm_device.c')
-rw-r--r--src/lib/ecore_drm/ecore_drm_device.c149
1 files changed, 51 insertions, 98 deletions
diff --git a/src/lib/ecore_drm/ecore_drm_device.c b/src/lib/ecore_drm/ecore_drm_device.c
index c571b9333b..4b7c4e3017 100644
--- a/src/lib/ecore_drm/ecore_drm_device.c
+++ b/src/lib/ecore_drm/ecore_drm_device.c
@@ -151,131 +151,84 @@ EAPI Ecore_Drm_Device *
151ecore_drm_device_find(const char *name, const char *seat) 151ecore_drm_device_find(const char *name, const char *seat)
152{ 152{
153 Ecore_Drm_Device *dev = NULL; 153 Ecore_Drm_Device *dev = NULL;
154 struct udev_enumerate *uenum; 154 Eina_Bool found = EINA_FALSE;
155 struct udev_list_entry *uentry; 155 Eina_List *devs, *l;
156 struct udev_device *udevice, *tmpdevice = NULL, *pcidevice; 156 const char *device, *tmpdevice;
157 const char *path = NULL, *devseat = NULL;
158 157
159 /* check for existing udev reference */ 158 /* try to get a list of drm devics */
160 if (!udev) return NULL; 159 if (!(devs = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRM, name)))
160 return NULL;
161 161
162 /* setup udev enumerator */ 162 DBG("Find Drm Device: %s", name);
163 uenum = udev_enumerate_new(udev);
164 udev_enumerate_add_match_subsystem(uenum, "drm");
165 udev_enumerate_add_match_subsystem(uenum, "card[0-9]*");
166 163
167 /* ask udev for list of drm devices */ 164 EINA_LIST_FOREACH(devs, l, device)
168 udev_enumerate_scan_devices(uenum);
169
170 /* loop list of returned devices */
171 udev_list_entry_foreach(uentry, udev_enumerate_get_list_entry(uenum))
172 { 165 {
173 /* get device path */ 166 const char *devpath;
174 path = udev_list_entry_get_name(uentry); 167 const char *devseat;
168 const char *devparent;
175 169
176 /* get udev device */ 170 if (!(devpath = eeze_udev_syspath_get_devpath(device)))
177 if (!(udevice = udev_device_new_from_syspath(udev, path)))
178 continue; 171 continue;
179 172
180 /* if we are looking for a certain device, then compare names */ 173 DBG("Found Drm Device");
181 if (name) 174 DBG("\tDevice: %s", device);
182 { 175 DBG("\tDevpath: %s", devpath);
183 if (strcmp(name, udev_device_get_devnode(udevice)))
184 {
185 udev_device_unref(udevice);
186 continue;
187 }
188 }
189 176
190 /* get this devices' seat */ 177 if ((name) && (strcmp(name, devpath))) goto cont;
191 devseat = udev_device_get_property_value(udevice, "ID_SEAT");
192 if (!devseat) devseat = "seat0";
193 178
194 /* if we are looking for a device on a certain seat, compare it */ 179 if (!(devseat = eeze_udev_syspath_get_property(device, "ID_SEAT")))
195 if (seat) 180 devseat = eina_stringshare_add("seat0");
196 {
197 if (strcmp(seat, devseat))
198 {
199 udev_device_unref(udevice);
200 continue;
201 }
202 }
203 else
204 {
205 /* no seat name passed to use. check default */
206 if (strcmp(devseat, "seat0"))
207 {
208 udev_device_unref(udevice);
209 continue;
210 }
211 }
212 181
213 /* try to find the boot_vga attribute */ 182 if ((seat) && (strcmp(seat, devseat)))
214 if ((pcidevice = 183 goto cont;
215 udev_device_get_parent_with_subsystem_devtype(udevice, "pci", NULL))) 184 else if (strcmp(devseat, "seat0"))
185 goto cont;
186
187 devparent = eeze_udev_syspath_get_parent_filtered(device, "pci", NULL);
188 if (devparent)
216 { 189 {
217 const char *id; 190 const char *id;
218 191
219 if ((id = udev_device_get_sysattr_value(pcidevice, "boot_vga"))) 192 if ((id = eeze_udev_syspath_get_sysattr(devparent, "boot_vga")))
220 { 193 {
221 if (!strcmp(id, "1")) 194 if (!strcmp(id, "1")) found = EINA_TRUE;
222 { 195 eina_stringshare_del(id);
223 if (tmpdevice) udev_device_unref(tmpdevice);
224 tmpdevice = udevice;
225 break;
226 }
227 } 196 }
197
198 eina_stringshare_del(devparent);
228 } 199 }
229 200
230 if (!tmpdevice) 201cont:
231 tmpdevice = udevice; 202 eina_stringshare_del(devpath);
232 else 203 if (found)
233 udev_device_unref(udevice); 204 {
205 tmpdevice = eina_stringshare_add(device);
206 break;
207 }
234 } 208 }
235 209
236 /* destroy the enumerator */ 210 EINA_LIST_FREE(devs, device)
237 udev_enumerate_unref(uenum); 211 eina_stringshare_del(device);
238 212
239 if (tmpdevice) 213 if (!found) return NULL;
240 {
241 DBG("Found Drm Device");
242 DBG("\tFilename: %s", udev_device_get_devnode(tmpdevice));
243 DBG("\tDriver: %s", udev_device_get_driver(tmpdevice));
244 DBG("\tDevpath: %s", udev_device_get_devpath(tmpdevice));
245 DBG("\tSyspath: %s", udev_device_get_syspath(tmpdevice));
246 DBG("\tSysname: %s", udev_device_get_sysname(tmpdevice));
247
248 /* try to allocate space for return device structure */
249 if ((dev = calloc(1, sizeof(Ecore_Drm_Device))))
250 {
251 const char *id, *seat_id;
252 214
253 /* set device name */ 215 if ((dev = calloc(1, sizeof(Ecore_Drm_Device))))
254 dev->drm.name = 216 {
255 eina_stringshare_add(udev_device_get_devnode(tmpdevice)); 217 dev->drm.name = eeze_udev_syspath_get_devpath(tmpdevice);
256 218 dev->drm.path = eina_stringshare_add(tmpdevice);
257 /* set device path */
258 dev->drm.path =
259 eina_stringshare_add(udev_device_get_syspath(tmpdevice));
260 219
261 /* store id for this device */ 220 dev->id = eeze_udev_syspath_get_sysnum(tmpdevice);
262 if ((id = udev_device_get_sysnum(tmpdevice)))
263 dev->id = atoi(id);
264 221
265 /* set dev seat_id */ 222 dev->seat = eeze_udev_syspath_get_property(tmpdevice, "ID_SEAT");
266 seat_id = udev_device_get_property_value(tmpdevice, "ID_SEAT"); 223 if (!dev->seat) dev->seat = eina_stringshare_add("seat0");
267 if (!seat_id) seat_id = "seat0";
268 224
269 dev->seat = eina_stringshare_add(seat_id); 225 dev->format = 0;
226 dev->use_hw_accel = EINA_FALSE;
270 227
271 /* dev->format = GBM_FORMAT_XRGB8888; */ 228 DBG("Using Drm Device: %s", dev->drm.name);
272 dev->format = 0;
273 dev->use_hw_accel = EINA_FALSE;
274 }
275 } 229 }
276 230
277 /* release device reference */ 231 eina_stringshare_del(tmpdevice);
278 udev_device_unref(tmpdevice);
279 232
280 return dev; 233 return dev;
281} 234}