Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 5 additions & 32 deletions bolt/src/run.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

const { Remote } = require('./Remote.cjs');
const runtime = require('./runtime-config.cjs');
const { makeTemplate, applyGPUConfig } = require('./runtime-config.cjs');
const config = require('./config.cjs');

Expand Down Expand Up @@ -302,45 +303,17 @@ function run(remoteName, pkg, options) {
}

setupResources(remote, pkg);

const waylandSocketPath = getWaylandSocketPath(pkg);
if (remote.socketExists(waylandSocketPath)) {
bundleConfig.mounts.push({
source: waylandSocketPath,
destination: waylandSocketPath,
type: "bind",
options: [
"rbind",
"rw"
]
});
const pathArray = waylandSocketPath.split("/");
bundleConfig.process.env.push(`WAYLAND_DISPLAY=${pathArray.pop()}`);
bundleConfig.process.env.push(`XDG_RUNTIME_DIR=${pathArray.join("/")}`);
}

const rialtoSocketPath = getRialtoSocketPath(pkg);
if (remote.socketExists(rialtoSocketPath)) {
bundleConfig.mounts.push({
source: rialtoSocketPath,
destination: rialtoSocketPath,
type: "bind",
options: [
"rbind",
"rw"
]
});
bundleConfig.process.env.push(`RIALTO_SOCKET_PATH=${rialtoSocketPath}`);
}
const waylandAvailable = runtime.configureWaylandSocket(remote, bundleConfig, getWaylandSocketPath(pkg));
const rialtoAvailable = runtime.configureRialtoSocket(remote, bundleConfig, getRialtoSocketPath(pkg));

layerDirs.reverse();
prepareBundle(remote, pkg, bundleConfig, layerDirs, options);

if (!remote.socketExists(rialtoSocketPath)) {
if (!rialtoAvailable) {
console.warn('\n\n\x1b[31mRialto socket not available! Playback not supported!\x1b[0m\n\n');
}

if (!remote.socketExists(waylandSocketPath)) {
if (!waylandAvailable) {
console.warn('\n\n\x1b[31mWayland socket not available! Graphics rendering not available!\x1b[0m\n\n');
}

Expand Down
59 changes: 53 additions & 6 deletions bolt/src/runtime-config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -302,17 +302,21 @@ function hexToNumber(str) {
throw new Error(`Cannot parse ${str} as hex number`);
}

function applyAccessRights(remote, groupIds, path, perm, groupName) {
if (perm[7] === "r" && perm[8] === "w") {
} else if (groupIds.includes(groupName) && perm[4] === "r" && perm[5] === "w") {
} else {
console.warn(`Changing access rights for ${path}! (was ${perm}, group: ${groupName})`);
remote.exec(`chmod a+rw ${path}`);
}
}

function processDevNodeEntry(remote, config, devNode, groupIds) {
try {
const [perm, majorHex, minorHex, groupName] = remote.exec(`stat -c '%A:%t:%T:%G' ${devNode}`).trim().split(":");
if (perm.length === 10 && (perm[0] === "c" || perm[0] === "b")) {
addDevice(config, devNode, perm[0], hexToNumber(majorHex), hexToNumber(minorHex));
if (perm[7] === "r" && perm[8] === "w") {
} else if (groupIds.includes(groupName) && perm[4] === "r" && perm[5] === "w") {
} else {
console.warn(`Changing access rights for ${devNode}! (was ${perm}, group: ${groupName})`);
remote.exec(`chmod a+rw ${devNode}`);
}
applyAccessRights(remote, groupIds, devNode, perm, groupName);
} else {
throw new Error(`not a device (perm: ${perm})`);
}
Expand Down Expand Up @@ -386,5 +390,48 @@ function applyGPUConfig(remote, config, gpuConfig) {
}
}

function configureWaylandSocket(remote, bundleConfig, waylandSocketPath) {
if (remote.socketExists(waylandSocketPath)) {
const [perm, groupName] = remote.exec(`stat -c '%A:%G' ${waylandSocketPath}`).trim().split(":");
applyAccessRights(remote, [], waylandSocketPath, perm, groupName);

bundleConfig.mounts.push({
source: waylandSocketPath,
destination: waylandSocketPath,
type: "bind",
options: [
"rbind",
"rw"
]
});
const pathArray = waylandSocketPath.split("/");
bundleConfig.process.env.push(`WAYLAND_DISPLAY=${pathArray.pop()}`);
bundleConfig.process.env.push(`XDG_RUNTIME_DIR=${pathArray.join("/")}`);
return true;
}
return false;
}

function configureRialtoSocket(remote, bundleConfig, rialtoSocketPath) {
if (remote.socketExists(rialtoSocketPath)) {
const [perm, groupName] = remote.exec(`stat -c '%A:%G' ${rialtoSocketPath}`).trim().split(":");
applyAccessRights(remote, [], rialtoSocketPath, perm, groupName);
bundleConfig.mounts.push({
source: rialtoSocketPath,
destination: rialtoSocketPath,
type: "bind",
options: [
"rbind",
"rw"
]
});
bundleConfig.process.env.push(`RIALTO_SOCKET_PATH=${rialtoSocketPath}`);
return true;
}
return false;
}

exports.makeTemplate = makeTemplate;
exports.applyGPUConfig = applyGPUConfig;
exports.configureWaylandSocket = configureWaylandSocket;
exports.configureRialtoSocket = configureRialtoSocket;
21 changes: 21 additions & 0 deletions gpu-layer-poc/brcm974116sff.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"vendorGpuSupport": {
"devNodes": [
"/dev/nexus",
"/dev/nexusmem",
"/dev/dri/card0",
"/dev/dri/card1",
"/dev/dri/renderD128"
],
"groupIds": [
"video"
],
"files": [
{
"type": "bind",
"source": "/tmp/nxserver_ipc",
"destination": "/tmp/nxserver_ipc"
}
]
}
}
25 changes: 19 additions & 6 deletions gpu-layer-poc/setup-gpu-layer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ LIBS+=(/usr/lib/libGLESv2.so)
LIBS+=(/usr/lib/libGLESv2.so.2)
LIBS+=(/usr/lib/libwayland-egl.so.1)

declare -A FILE_INFO_FALLBACK

FILE_INFO_FALLBACK[/usr/lib/libEGL.so]="'libEGL.so' -> 'libEGL.so.1'"
FILE_INFO_FALLBACK[/usr/lib/libGLESv1_CM.so]="'libGLESv1_CM.so' -> 'libGLESv1_CM.so.1'"
FILE_INFO_FALLBACK[/usr/lib/libGLESv2.so]="'libGLESv2.so' -> 'libGLESv2.so.2'"

BASE_LIBS+=(libwayland-server.so)
BASE_LIBS+=(libwayland-client.so)
BASE_LIBS+=(libdl.so)
Expand Down Expand Up @@ -115,11 +121,18 @@ function add_deps {
function main {
local config_name
local tmp_config

config_name=$(get_platform)-$(get_version).json

if [[ ! -f "${config_name}" ]]; then
echo "File ${config_name} not found, platform not supported."
local platform
local firmware_version

platform=$(get_platform)
firmware_version=$(get_version)

if [[ -f ${platform}-${firmware_version}.json ]]; then
config_name="${platform}-${firmware_version}.json"
elif [[ -f ${platform}.json ]]; then
config_name="${platform}.json"
else
echo "Config for platform ${platform} not found (${firmware_version})"
exit 2
fi

Expand All @@ -138,7 +151,7 @@ function main {
PROCESSED_LIBS_SET[${lib}]=1

local file_info
file_info=$(remote stat -c '%N' "${lib}")
file_info=$(remote stat -c '%N' "${lib}" 2> /dev/null || echo "${FILE_INFO_FALLBACK[${lib}]}")

echo "Processing ${lib}..."

Expand Down