driconfig: Add support for device specific config
Add support for driconf overrides on a per-device level, for cases where we don't want to override behavior for all devices supported by a particular driver. Signed-off-by: Rob Clark <robdclark@chromium.org> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12135>
This commit is contained in:
@@ -31,7 +31,8 @@ TODO: document the other workarounds.
|
||||
<!DOCTYPE driconf [
|
||||
<!ELEMENT driconf (device+)>
|
||||
<!ELEMENT device (application | engine)+>
|
||||
<!ATTLIST device driver CDATA #IMPLIED>
|
||||
<!ATTLIST device driver CDATA #IMPLIED
|
||||
device CDATA #IMPLIED>
|
||||
<!ELEMENT application (option+)>
|
||||
<!ATTLIST application name CDATA #REQUIRED
|
||||
executable CDATA #IMPLIED
|
||||
|
||||
@@ -68,6 +68,7 @@ class Device(object):
|
||||
def __init__(self, xml):
|
||||
self.cname = cname('device')
|
||||
self.driver = xml.attrib.get('driver', None)
|
||||
self.device = xml.attrib.get('device', None)
|
||||
self.applications = []
|
||||
self.engines = []
|
||||
|
||||
@@ -133,6 +134,7 @@ struct driconf_engine {
|
||||
|
||||
struct driconf_device {
|
||||
const char *driver;
|
||||
const char *device;
|
||||
unsigned num_engines;
|
||||
const struct driconf_engine *engines;
|
||||
unsigned num_applications;
|
||||
@@ -196,6 +198,9 @@ static const struct driconf_application ${device.cname}_applications[] = {
|
||||
static const struct driconf_device ${device.cname} = {
|
||||
% if device.driver:
|
||||
.driver = "${device.driver}",
|
||||
% endif
|
||||
% if device.device:
|
||||
.device = "${device.device}",
|
||||
% endif
|
||||
.num_engines = ${len(device.engines)},
|
||||
% if len(device.engines) > 0:
|
||||
|
||||
@@ -143,7 +143,7 @@ TEST_F(xmlconfig_test, copy_cache)
|
||||
* user's homedir/environment that would override us.
|
||||
*/
|
||||
driParseConfigFiles(&cache, &options,
|
||||
0, "driver", "drm",
|
||||
0, "driver", "drm", NULL,
|
||||
NULL, 0,
|
||||
NULL, 0);
|
||||
|
||||
@@ -184,7 +184,7 @@ xmlconfig_test::drirc_init(const char *driver, const char *drm,
|
||||
* based on the setting of $HOME by meson.build.
|
||||
*/
|
||||
driParseConfigFiles(&cache, &options,
|
||||
0, driver, drm,
|
||||
0, driver, drm, NULL,
|
||||
app, appver,
|
||||
engine, enginever);
|
||||
|
||||
|
||||
@@ -595,6 +595,7 @@ struct OptConfData {
|
||||
int screenNum;
|
||||
const char *driverName, *execName;
|
||||
const char *kernelDriverName;
|
||||
const char *deviceName;
|
||||
const char *engineName;
|
||||
const char *applicationName;
|
||||
uint32_t engineVersion;
|
||||
@@ -648,11 +649,12 @@ static void
|
||||
parseDeviceAttr(struct OptConfData *data, const char **attr)
|
||||
{
|
||||
uint32_t i;
|
||||
const char *driver = NULL, *screen = NULL, *kernel = NULL;
|
||||
const char *driver = NULL, *screen = NULL, *kernel = NULL, *device = NULL;
|
||||
for (i = 0; attr[i]; i += 2) {
|
||||
if (!strcmp(attr[i], "driver")) driver = attr[i+1];
|
||||
else if (!strcmp(attr[i], "screen")) screen = attr[i+1];
|
||||
else if (!strcmp(attr[i], "kernel_driver")) kernel = attr[i+1];
|
||||
else if (!strcmp(attr[i], "device")) device = attr[i+1];
|
||||
else XML_WARNING("unknown device attribute: %s.", attr[i]);
|
||||
}
|
||||
if (driver && strcmp(driver, data->driverName))
|
||||
@@ -660,6 +662,9 @@ parseDeviceAttr(struct OptConfData *data, const char **attr)
|
||||
else if (kernel && (!data->kernelDriverName ||
|
||||
strcmp(kernel, data->kernelDriverName)))
|
||||
data->ignoringDevice = data->inDevice;
|
||||
else if (device && (!data->deviceName ||
|
||||
strcmp(device, data->deviceName)))
|
||||
data->ignoringDevice = data->inDevice;
|
||||
else if (screen) {
|
||||
driOptionValue screenNum;
|
||||
if (!parseValue(&screenNum, DRI_INT, screen))
|
||||
@@ -1059,6 +1064,7 @@ parseStaticConfig(struct OptConfData *data)
|
||||
const struct driconf_device *d = driconf[i];
|
||||
const char *devattr[] = {
|
||||
"driver", d->driver,
|
||||
"device", d->device,
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -1149,6 +1155,7 @@ void
|
||||
driParseConfigFiles(driOptionCache *cache, const driOptionCache *info,
|
||||
int screenNum, const char *driverName,
|
||||
const char *kernelDriverName,
|
||||
const char *deviceName,
|
||||
const char *applicationName, uint32_t applicationVersion,
|
||||
const char *engineName, uint32_t engineVersion)
|
||||
{
|
||||
@@ -1159,6 +1166,7 @@ driParseConfigFiles(driOptionCache *cache, const driOptionCache *info,
|
||||
userData.screenNum = screenNum;
|
||||
userData.driverName = driverName;
|
||||
userData.kernelDriverName = kernelDriverName;
|
||||
userData.deviceName = deviceName;
|
||||
userData.applicationName = applicationName ? applicationName : "";
|
||||
userData.applicationVersion = applicationVersion;
|
||||
userData.engineName = engineName ? engineName : "";
|
||||
|
||||
@@ -139,6 +139,7 @@ void driParseOptionInfo(driOptionCache *info,
|
||||
void driParseConfigFiles(driOptionCache *cache, const driOptionCache *info,
|
||||
int screenNum, const char *driverName,
|
||||
const char *kernelDriverName,
|
||||
const char *deviceName,
|
||||
const char *applicationName, uint32_t applicationVersion,
|
||||
const char *engineName, uint32_t engineVersion);
|
||||
/** \brief Destroy option info
|
||||
|
||||
Reference in New Issue
Block a user