led: Add touchled resource driver 90/312890/1
authorYunhee Seo <yuni.seo@samsung.com>
Fri, 14 Jun 2024 07:27:31 +0000 (16:27 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Mon, 17 Jun 2024 05:53:36 +0000 (14:53 +0900)
New attribute:
 - id: DEVICED_TOUCHLED_ATTR_INT_BACKLIGHT
 - type: SYSCOMMON_RESMAN_DATA_TYPE_INT
 - setter: O
 - getter: X

There is touchled function usage case from plugin-backend side,
therefore touchled resource driver is newly added.
To control touchled key manipulation, above attribute is added.

Change-Id: Id8fa30d4424b3536fc0c510db5592b90931c0d96
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
src/led/touchled-resource.c [new file with mode: 0644]

diff --git a/src/led/touchled-resource.c b/src/led/touchled-resource.c
new file mode 100644 (file)
index 0000000..b2a5d59
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * deviced
+ *
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <stdio.h>
+#include <stdint.h>
+
+#include <libsyscommon/resource-manager.h>
+#include <libsyscommon/resource-type.h>
+#include <system/syscommon-plugin-deviced-common-interface.h>
+#include <system/syscommon-plugin-deviced-touchled-interface.h>
+
+#include "shared/common.h"
+#include "touch-key.h"
+
+typedef union {
+       int32_t i32;
+       int64_t i64;
+       uint32_t u32;
+       uint64_t u64;
+       double d;
+       void* p;
+       bool b;
+} resource_attr_data_t;
+
+static int set_touchled_attr_data(int resource_id,
+       const struct syscommon_resman_resource_attribute *attr,
+       const void *data, int count)
+{
+       if (!data)
+               return -EINVAL;
+
+       switch (attr->id) {
+       case DEVICED_TOUCHLED_ATTR_INT_BACKLIGHT:
+               {
+                       enum syscommon_deviced_touchled_option_type touchled_opt = *(enum syscommon_deviced_touchled_option_type *) data;
+                       return touchled_control_backlight(touchled_opt);
+               }
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+static const struct syscommon_resman_resource_attribute touchled_attrs[] = {
+       {
+               .name = "DEVICED_TOUCHLED_ATTR_INT_BACKLIGHT",
+               .id = DEVICED_TOUCHLED_ATTR_INT_BACKLIGHT,
+               .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+               .flag = SYSCOMMON_RESMAN_RESOURCE_FLAG_PUBLIC,
+               .ops = {
+                       .set = set_touchled_attr_data,
+                       .is_supported = syscommon_resman_resource_attr_supported_always,
+               },
+       }
+};
+
+static const struct syscommon_resman_resource_driver deviced_touchled_driver = {
+       .name           = "touchled",
+       .type           = DEVICED_RESOURCE_TYPE_TOUCHLED,
+       .flag           = SYSCOMMON_RESMAN_RESOURCE_DRIVER_FLAG_COUNT_ONLY_ONE,
+       .attrs          = touchled_attrs,
+       .num_attrs      = ARRAY_SIZE(touchled_attrs),
+};
+SYSCOMMON_RESMAN_RESOURCE_DRIVER_REGISTER(&deviced_touchled_driver);
\ No newline at end of file