#define CPU_ATTR_AVAILABLE_MIN_FREQ BIT(3) /* DATA_TYPE_INT */
#define CPU_ATTR_AVAILABLE_MAX_FREQ BIT(4) /* DATA_TYPE_INT */
#define CPU_ATTR_CUR_GOVERNOR BIT(5) /* DATA_TYPE_STRING */
+#define CPU_ATTR_NAME BIT(6) /* DATA_TYPE_STRING */
#define CPU_CTRL_CLUSTER_ID BIT(0)
#define BUS_ATTR_AVAILABLE_MIN_FREQ BIT(3) /* DATA_TYPE_INT */
#define BUS_ATTR_AVAILABLE_MAX_FREQ BIT(4) /* DATA_TYPE_INT */
#define BUS_ATTR_CUR_GOVERNOR BIT(5) /* DATA_TYPE_STRING */
+#define BUS_ATTR_NAME BIT(6) /* DATA_TYPE_STRING */
#define BUS_CTRL_DEVICE_ID BIT(0)
#define GPU_ATTR_AVAILABLE_MIN_FREQ BIT(3) /* DATA_TYPE_INT */
#define GPU_ATTR_AVAILABLE_MAX_FREQ BIT(4) /* DATA_TYPE_INT */
#define GPU_ATTR_CUR_GOVERNOR BIT(5) /* DATA_TYPE_STRING */
+#define GPU_ATTR_NAME BIT(6) /* DATA_TYPE_STRING */
#define GPU_CTRL_DEVICE_ID BIT(0)
/* Display Resource */
#define DISPLAY_ATTR_FPS BIT(0) /* DATA_TYPE_DOUBLE */
+#define DISPLAY_ATTR_NAME BIT(1) /* DATA_TYPE_STRING */
#define DISPLAY_CTRL_DEVICE_ID BIT(0)
#define PROCESS_ATTR_MEM_RSS_PERCENT BIT(3) /* DATA_TYPE_DOUBLE */
#define PROCESS_ATTR_DISK_READ_BPS BIT(4) /* DATA_TYPE_UINT */
#define PROCESS_ATTR_DISK_WRITE_BPS BIT(5) /* DATA_TYPE_UINT */
-#define PROCESS_ATTR_COMM BIT(6) /* DATA_TYPE_STRING */
+#define PROCESS_ATTR_NAME BIT(6) /* DATA_TYPE_STRING */
#define PROCESS_ATTR_PGID BIT(7) /* DATA_TYPE_INT */
#define PROCESS_ATTR_PPID BIT(8) /* DATA_TYPE_INT */
#define PROCESS_ATTR_MEM_PSS BIT(9) /* DATA_TYPE_UINT64 */
/* Process List Resource */
#define PROCESS_GROUP_ATTR_PID_LIST BIT(0) /* DATA_TYPE_ARRAY(INT) */
-#define PROCESS_GROUP_ATTR_COMM_LIST BIT(1) /* DATA_TYPE_ARRAY(STRING) */
+#define PROCESS_GROUP_ATTR_NAME_LIST BIT(1) /* DATA_TYPE_ARRAY(STRING) */
#define PROCESS_GROUP_ATTR_CPU_UTIL BIT(2) /* DATA_TYPE_DOUBLE */
#define PROCESS_GROUP_ATTR_DISK_READ_BPS BIT(3) /* DATA_TYPE_UINT */
#define PROCESS_GROUP_ATTR_DISK_WRITE_BPS BIT(4) /* DATA_TYPE_UINT */
return 0;
}
-static int bus_get_curr_governor(struct resource *res,
+static int bus_get_string_value(struct resource *res,
const struct resource_attribute *attr,
void *data)
{
- struct bus_context *ctx;;
+ struct bus_context *ctx;
char *buf = (char *)data;
int val;
return -EINVAL;
}
- val = hal_power_dvfs_get_curr_governor(get_resource_type(res),
- ctx->device_name, buf);
- if (val < 0)
- return -EINVAL;
+ switch (attr->id) {
+ case BUS_ATTR_CUR_GOVERNOR:
+ val = hal_power_dvfs_get_curr_governor(get_resource_type(res),
+ ctx->device_name, buf);
+ if (val < 0)
+ return -EINVAL;
+ break;
+ case BUS_ATTR_NAME:
+ strncpy(buf, ctx->device_name, BUFF_MAX);
+ break;
+ }
return 0;
}
.id = BUS_ATTR_CUR_GOVERNOR,
.type = DATA_TYPE_STRING,
.ops = {
- .get = bus_get_curr_governor,
+ .get = bus_get_string_value,
+ }
+ }, {
+ .name = "BUS_ATTR_NAME",
+ .id = BUS_ATTR_NAME,
+ .type = DATA_TYPE_STRING,
+ .ops = {
+ .get = bus_get_string_value,
}
},
};
return 0;
}
-static int cpu_get_curr_governor(struct resource *res,
+static int cpu_get_string_value(struct resource *res,
const struct resource_attribute *attr,
void *data)
{
return -EINVAL;
}
- val = hal_power_dvfs_get_curr_governor(get_resource_type(res),
- ctx->device_name, buf);
- if (val < 0)
- return -EINVAL;
+ switch (attr->id) {
+ case CPU_ATTR_CUR_GOVERNOR:
+ val = hal_power_dvfs_get_curr_governor(get_resource_type(res),
+ ctx->device_name, buf);
+ if (val < 0)
+ return -EINVAL;
+ break;
+ case CPU_ATTR_NAME:
+ strncpy(buf, ctx->device_name, BUFF_MAX);
+ break;
+ }
return 0;
}
.id = CPU_ATTR_CUR_GOVERNOR,
.type = DATA_TYPE_STRING,
.ops = {
- .get = cpu_get_curr_governor,
+ .get = cpu_get_string_value,
+ }
+ }, {
+ .name = "CPU_ATTR_NAME",
+ .id = CPU_ATTR_NAME,
+ .type = DATA_TYPE_STRING,
+ .ops = {
+ .get = cpu_get_string_value,
}
},
};
#define DBUS_ENLIGHTENMENT_INTERFACE "org.enlightenment.wm.info"
#define DBUS_ENLIGHTENMENT_FPS_FUNC "get_fps_info"
+struct display_context {
+ char *device_name;
+ int index;
+};
+
struct display_fps_data {
unsigned int type;
char output[128];
const struct resource_attribute *attr,
void *data)
{
+ struct display_context *ctx;
GDBusConnection *conn;
GDBusMessage *msg, *reply;
GVariant *result, *value;
GError *err = NULL;
struct display_fps_data fps_data;
- int *disp_id;
double *fps = (double *)data;
int ret = 0;
if (!res || !attr || !data)
return -EINVAL;
- disp_id = get_resource_privdata(res);
- if (!disp_id)
+ ctx = get_resource_privdata(res);
+ if (!ctx)
return -EINVAL;
- if (*disp_id < 0) {
+ if (!ctx->device_name) {
_E("%s: DISPLAY_CTRL_DEVICE_ID is not yet initialized\n",
get_resource_name(res));
return -EINVAL;
}
/* Get the fps information according to the index of resource_device */
- value = g_variant_get_child_value(result, *disp_id);
+ value = g_variant_get_child_value(result, ctx->index);
g_variant_get(value, "(usiud)",
&fps_data.type, fps_data.output, &fps_data.zpos,
&fps_data.window, &fps_data.fps);
return ret;
}
+static int display_get_name(struct resource *res,
+ const struct resource_attribute *attr,
+ void *data)
+{
+ struct display_context *ctx;
+ char *buf = (char *)data;
+
+ if (!res || !attr || !data)
+ return -EINVAL;
+
+ ctx = get_resource_privdata(res);
+ if (!ctx)
+ return -EINVAL;
+
+ if (!ctx->device_name) {
+ _E("%s: DISPLAY_CTRL_DEVICE_ID is not yet initialized\n",
+ get_resource_name(res));
+ return -EINVAL;
+ }
+
+ strncpy(buf, ctx->device_name, BUFF_MAX);
+
+ return 0;
+}
+
static const struct resource_attribute display_attrs[] = {
{
.name = "DISPLAY_ATTR_FPS",
.ops = {
.get = display_get_fps,
},
+ }, {
+ .name = "DISPLAY_ATTR_NAME",
+ .id = DISPLAY_ATTR_NAME,
+ .type = DATA_TYPE_STRING,
+ .ops = {
+ .get = display_get_name,
+ },
},
};
const struct resource_control *ctrl,
const void *data)
{
- int *disp_id = NULL;
+ struct display_context *ctx;
+ const struct resource_device *device;
+ int resource_index = (int)(intptr_t)data;
if (!res || !ctrl)
return -EINVAL;
- disp_id = get_resource_privdata(res);
- if (!disp_id)
+ ctx = get_resource_privdata(res);
+ if (!ctx)
+ return -EINVAL;
+
+ device = find_resource_device(get_resource_type(res), resource_index);
+ if (!device) {
+ _E("Not available resource: type: %s, index: %d\n",
+ get_resource_name(res), resource_index);
return -EINVAL;
+ }
- *disp_id = (int)(intptr_t)data;
+ if (ctx->device_name)
+ free(ctx->device_name);
- set_resource_privdata(res, disp_id);
+ ctx->device_name = g_strdup(device->name);
+ ctx->index = resource_index;
return 0;
}
static int display_init(struct resource *res)
{
- int *disp_id;
+ struct display_context *ctx;
- disp_id = malloc(sizeof(int));
- if (!disp_id)
+ ctx = calloc(1, sizeof(struct display_context));
+ if (!ctx)
return -ENOMEM;
- *disp_id = -1;
+ ctx->index = -1;
- set_resource_privdata(res, disp_id);
+ set_resource_privdata(res, ctx);
return 0;
}
static void display_exit(struct resource *res)
{
- int *disp_id;
+ struct display_context *ctx;
if (!res)
return;
- disp_id = get_resource_privdata(res);
- if (!disp_id)
+ ctx = get_resource_privdata(res);
+ if (!ctx)
return;
- free(disp_id);
+ if (ctx->device_name)
+ free(ctx->device_name);
+
+ free(ctx);
set_resource_privdata(res, NULL);
}
return 0;
}
-static int gpu_get_curr_governor(struct resource *res,
+static int gpu_get_string_value(struct resource *res,
const struct resource_attribute *attr,
void *data)
{
return -EINVAL;
}
- val = hal_power_dvfs_get_curr_governor(get_resource_type(res),
- ctx->device_name, buf);
- if (val < 0)
- return -EINVAL;
+ switch (attr->id) {
+ case GPU_ATTR_CUR_GOVERNOR:
+ val = hal_power_dvfs_get_curr_governor(get_resource_type(res),
+ ctx->device_name, buf);
+ if (val < 0)
+ return -EINVAL;
+ break;
+ case GPU_ATTR_NAME:
+ strncpy(buf, ctx->device_name, BUFF_MAX);
+ break;
+ }
return 0;
}
.id = GPU_ATTR_CUR_GOVERNOR,
.type = DATA_TYPE_STRING,
.ops = {
- .get = gpu_get_curr_governor,
+ .get = gpu_get_string_value,
+ }
+ }, {
+ .name = "GPU_ATTR_NAME",
+ .id = GPU_ATTR_NAME,
+ .type = DATA_TYPE_STRING,
+ .ops = {
+ .get = gpu_get_string_value,
}
},
};
return 0;
}
-static int process_group_get_comm_list(struct resource *res,
+static int process_group_get_name_list(struct resource *res,
const struct resource_attribute *attr,
void *data)
{
.is_supported = resource_attr_supported_always,
},
}, {
- .name = "PROCESS_GROUP_ATTR_COMM_LIST",
- .id = PROCESS_GROUP_ATTR_COMM_LIST,
+ .name = "PROCESS_GROUP_ATTR_NAME_LIST",
+ .id = PROCESS_GROUP_ATTR_NAME_LIST,
.type = DATA_TYPE_ARRAY,
.ops = {
- .get = process_group_get_comm_list,
+ .get = process_group_get_name_list,
.is_supported = resource_attr_supported_always,
},
}, {
}
switch (attr->id) {
- case PROCESS_ATTR_COMM:
+ case PROCESS_ATTR_NAME:
strncpy((char *)data, ctx->comm, TS_COMM_LEN);
break;
case PROCESS_ATTR_PGID:
.is_supported = resource_attr_supported_always,
},
}, {
- .name = "PROCESS_ATTR_COMM",
- .id = PROCESS_ATTR_COMM,
+ .name = "PROCESS_ATTR_NAME",
+ .id = PROCESS_ATTR_NAME,
.type = DATA_TYPE_STRING,
.ops = {
.get = process_get_context_data,