The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ipc: Add device_get_brightness and device_set_brightness

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2426>

averyv b521caa1 f1079898

+89 -1
+36
src/xrt/ipc/client/ipc_client_hmd.c
··· 271 271 u_device_free(&ich->base); 272 272 } 273 273 274 + static xrt_result_t 275 + ipc_client_hmd_get_brightness(struct xrt_device *xdev, float *out_brightness) 276 + { 277 + ipc_client_hmd_t *ich = ipc_client_hmd(xdev); 278 + struct ipc_connection *ipc_c = ich->ipc_c; 279 + xrt_result_t xret; 280 + 281 + ipc_client_connection_lock(ipc_c); 282 + 283 + xret = ipc_call_device_get_brightness(ipc_c, ich->device_id, out_brightness); 284 + IPC_CHK_ONLY_PRINT(ipc_c, xret, "ipc_call_device_get_brightness"); 285 + 286 + ipc_client_connection_unlock(ipc_c); 287 + 288 + return xret; 289 + } 290 + 291 + static xrt_result_t 292 + ipc_client_hmd_set_brightness(struct xrt_device *xdev, float brightness, bool relative) 293 + { 294 + ipc_client_hmd_t *ich = ipc_client_hmd(xdev); 295 + struct ipc_connection *ipc_c = ich->ipc_c; 296 + xrt_result_t xret; 297 + 298 + ipc_client_connection_lock(ipc_c); 299 + 300 + xret = ipc_call_device_set_brightness(ipc_c, ich->device_id, brightness, relative); 301 + IPC_CHK_ONLY_PRINT(ipc_c, xret, "ipc_call_device_set_brightness"); 302 + 303 + ipc_client_connection_unlock(ipc_c); 304 + 305 + return xret; 306 + } 307 + 274 308 /*! 275 309 * @public @memberof ipc_client_hmd 276 310 */ ··· 293 327 ich->base.is_form_factor_available = ipc_client_hmd_is_form_factor_available; 294 328 ich->base.get_visibility_mask = ipc_client_hmd_get_visibility_mask; 295 329 ich->base.destroy = ipc_client_hmd_destroy; 330 + ich->base.get_brightness = ipc_client_hmd_get_brightness; 331 + ich->base.set_brightness = ipc_client_hmd_set_brightness; 296 332 297 333 // Setup blend-modes. 298 334 ich->base.hmd->blend_mode_count = ipc_c->ism->hmd.blend_mode_count;
+36
src/xrt/ipc/server/ipc_server_handler.c
··· 17 17 18 18 #include "server/ipc_server.h" 19 19 #include "ipc_server_generated.h" 20 + #include "xrt/xrt_device.h" 21 + #include "xrt/xrt_results.h" 20 22 21 23 #ifdef XRT_GRAPHICS_SYNC_HANDLE_IS_FD 22 24 #include <unistd.h> ··· 2511 2513 struct xrt_device *xdev = get_xdev(ics, id); 2512 2514 return xrt_device_get_battery_status(xdev, out_present, out_charging, out_charge); 2513 2515 } 2516 + 2517 + xrt_result_t 2518 + ipc_handle_device_get_brightness(volatile struct ipc_client_state *ics, uint32_t id, float *out_brightness) 2519 + { 2520 + struct xrt_device *xdev = NULL; 2521 + xrt_result_t xret = validate_device_id(ics, id, &xdev); 2522 + if (xret != XRT_SUCCESS) { 2523 + U_LOG_E("Invalid device_id!"); 2524 + return xret; 2525 + } 2526 + 2527 + if (!xdev->supported.brightness_control) { 2528 + return XRT_ERROR_FEATURE_NOT_SUPPORTED; 2529 + } 2530 + 2531 + return xrt_device_get_brightness(xdev, out_brightness); 2532 + } 2533 + 2534 + xrt_result_t 2535 + ipc_handle_device_set_brightness(volatile struct ipc_client_state *ics, uint32_t id, float brightness, bool relative) 2536 + { 2537 + struct xrt_device *xdev = NULL; 2538 + xrt_result_t xret = validate_device_id(ics, id, &xdev); 2539 + if (xret != XRT_SUCCESS) { 2540 + U_LOG_E("Invalid device_id!"); 2541 + return xret; 2542 + } 2543 + 2544 + if (!xdev->supported.brightness_control) { 2545 + return XRT_ERROR_FEATURE_NOT_SUPPORTED; 2546 + } 2547 + 2548 + return xrt_device_set_brightness(xdev, brightness, relative); 2549 + }
+17 -1
src/xrt/ipc/shared/proto.json
··· 606 606 {"name": "charging", "type": "bool"}, 607 607 {"name": "charge", "type": "float"} 608 608 ] 609 - } 609 + }, 610 610 611 + "device_get_brightness": { 612 + "in": [ 613 + {"name": "id", "type": "uint32_t"} 614 + ], 615 + "out": [ 616 + {"name": "brightness", "type": "float"} 617 + ] 618 + }, 619 + 620 + "device_set_brightness": { 621 + "in": [ 622 + {"name": "id", "type": "uint32_t"}, 623 + {"name": "brightness", "type": "float"}, 624 + {"name": "relative", "type": "bool"} 625 + ] 626 + } 611 627 }