1af69d88dSmrg/*
2af69d88dSmrg * Copyright (C) 2013 Rob Clark <robclark@freedesktop.org>
3af69d88dSmrg *
4af69d88dSmrg * Permission is hereby granted, free of charge, to any person obtaining a
5af69d88dSmrg * copy of this software and associated documentation files (the "Software"),
6af69d88dSmrg * to deal in the Software without restriction, including without limitation
7af69d88dSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8af69d88dSmrg * and/or sell copies of the Software, and to permit persons to whom the
9af69d88dSmrg * Software is furnished to do so, subject to the following conditions:
10af69d88dSmrg *
11af69d88dSmrg * The above copyright notice and this permission notice (including the next
12af69d88dSmrg * paragraph) shall be included in all copies or substantial portions of the
13af69d88dSmrg * Software.
14af69d88dSmrg *
15af69d88dSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16af69d88dSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17af69d88dSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19af69d88dSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20af69d88dSmrg * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21af69d88dSmrg * SOFTWARE.
22af69d88dSmrg *
23af69d88dSmrg * Authors:
24af69d88dSmrg *    Rob Clark <robclark@freedesktop.org>
25af69d88dSmrg */
26af69d88dSmrg
27af69d88dSmrg#ifndef LOADER_H
28af69d88dSmrg#define LOADER_H
29af69d88dSmrg
3001e04c3fSmrg#include <stdbool.h>
3101e04c3fSmrg
3201e04c3fSmrg#ifdef __cplusplus
3301e04c3fSmrgextern "C" {
3401e04c3fSmrg#endif
3501e04c3fSmrg
369f464c52Smayastruct __DRIextensionRec;
379f464c52Smaya
38af69d88dSmrg/* Helpers to figure out driver and device name, eg. from pci-id, etc. */
39af69d88dSmrg
4001e04c3fSmrgint
4101e04c3fSmrgloader_open_device(const char *);
4201e04c3fSmrg
4301e04c3fSmrgint
4401e04c3fSmrgloader_open_render_node(const char *name);
45af69d88dSmrg
467ec681f3Smrgbool
47af69d88dSmrgloader_get_pci_id_for_fd(int fd, int *vendor_id, int *chip_id);
48af69d88dSmrg
49af69d88dSmrgchar *
5001e04c3fSmrgloader_get_driver_for_fd(int fd);
51af69d88dSmrg
527ec681f3Smrgvoid *
537ec681f3Smrgloader_open_driver_lib(const char *driver_name,
547ec681f3Smrg                       const char *lib_suffix,
557ec681f3Smrg                       const char **search_path_vars,
567ec681f3Smrg                       const char *default_search_path,
577ec681f3Smrg                       bool warn_on_fail);
587ec681f3Smrg
599f464c52Smayaconst struct __DRIextensionRec **
609f464c52Smayaloader_open_driver(const char *driver_name,
619f464c52Smaya                   void **out_driver_handle,
629f464c52Smaya                   const char **search_path_vars);
639f464c52Smaya
64af69d88dSmrgchar *
65af69d88dSmrgloader_get_device_name_for_fd(int fd);
66af69d88dSmrg
67af69d88dSmrg/* Function to get a different device than the one we are to use by default,
68af69d88dSmrg * if the user requests so and it is possible. The initial fd will be closed
6901e04c3fSmrg * if necessary. The returned fd is potentially a render-node.
70af69d88dSmrg */
71af69d88dSmrg
72af69d88dSmrgint
7301e04c3fSmrgloader_get_user_preferred_fd(int default_fd, bool *different_device);
74af69d88dSmrg
75af69d88dSmrg/* for logging.. keep this aligned with egllog.h so we can just use
76af69d88dSmrg * _eglLog directly.
77af69d88dSmrg */
78af69d88dSmrg
79af69d88dSmrg#define _LOADER_FATAL   0   /* unrecoverable error */
80af69d88dSmrg#define _LOADER_WARNING 1   /* recoverable error/problem */
81af69d88dSmrg#define _LOADER_INFO    2   /* just useful info */
82af69d88dSmrg#define _LOADER_DEBUG   3   /* useful info for debugging */
83af69d88dSmrg
849f464c52Smayatypedef void loader_logger(int level, const char *fmt, ...);
85af69d88dSmrgvoid
869f464c52Smayaloader_set_logger(loader_logger *logger);
87af69d88dSmrg
8801e04c3fSmrgchar *
8901e04c3fSmrgloader_get_extensions_name(const char *driver_name);
9001e04c3fSmrg
9101e04c3fSmrg#ifdef __cplusplus
9201e04c3fSmrg}
9301e04c3fSmrg#endif
9401e04c3fSmrg
95af69d88dSmrg#endif /* LOADER_H */
96