mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
libcamera: fix setting controls
Use the set_control function of v4l2 and libcamera also to set properties from a sequence.
This commit is contained in:
parent
cfb226b0fb
commit
bf8981ef61
2 changed files with 3 additions and 57 deletions
|
|
@ -833,15 +833,9 @@ static int impl_node_port_reuse_buffer(void *object,
|
|||
return res;
|
||||
}
|
||||
|
||||
static void set_control(struct impl *impl, struct port *port, uint32_t control_id, float value)
|
||||
{
|
||||
spa_log_error(impl->log, "Failed to set control");
|
||||
}
|
||||
|
||||
static int process_control(struct impl *impl, struct spa_pod_sequence *control)
|
||||
{
|
||||
struct spa_pod_control *c;
|
||||
struct port *port;
|
||||
|
||||
SPA_POD_SEQUENCE_FOREACH(control, c) {
|
||||
switch (c->type) {
|
||||
|
|
@ -851,9 +845,7 @@ static int process_control(struct impl *impl, struct spa_pod_sequence *control)
|
|||
struct spa_pod_object *obj = (struct spa_pod_object *) &c->value;
|
||||
|
||||
SPA_POD_OBJECT_FOREACH(obj, prop) {
|
||||
port = GET_OUT_PORT(impl, 0);
|
||||
set_control(impl, port, prop->key,
|
||||
SPA_POD_VALUE(struct spa_pod_float, &prop->value));
|
||||
spa_libcamera_set_control(impl, prop);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -325,7 +325,6 @@ static int impl_node_set_param(void *object,
|
|||
struct props *p = &this->props;
|
||||
struct spa_pod_object *obj = (struct spa_pod_object *) param;
|
||||
struct spa_pod_prop *prop;
|
||||
int res = 0;
|
||||
|
||||
if (param == NULL) {
|
||||
reset_props(p);
|
||||
|
|
@ -339,11 +338,9 @@ static int impl_node_set_param(void *object,
|
|||
sizeof(p->device)-1);
|
||||
break;
|
||||
default:
|
||||
res = spa_v4l2_set_control(this, prop->key, prop);
|
||||
spa_v4l2_set_control(this, prop->key, prop);
|
||||
break;
|
||||
}
|
||||
if (res < 0)
|
||||
return res;
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
@ -825,45 +822,9 @@ static int impl_node_port_reuse_buffer(void *object,
|
|||
return res;
|
||||
}
|
||||
|
||||
static uint32_t prop_to_control_id(uint32_t prop)
|
||||
{
|
||||
switch (prop) {
|
||||
case SPA_PROP_brightness:
|
||||
return V4L2_CID_BRIGHTNESS;
|
||||
case SPA_PROP_contrast:
|
||||
return V4L2_CID_CONTRAST;
|
||||
case SPA_PROP_saturation:
|
||||
return V4L2_CID_SATURATION;
|
||||
case SPA_PROP_hue:
|
||||
return V4L2_CID_HUE;
|
||||
case SPA_PROP_gamma:
|
||||
return V4L2_CID_GAMMA;
|
||||
case SPA_PROP_exposure:
|
||||
return V4L2_CID_EXPOSURE;
|
||||
case SPA_PROP_gain:
|
||||
return V4L2_CID_GAIN;
|
||||
case SPA_PROP_sharpness:
|
||||
return V4L2_CID_SHARPNESS;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void set_control(struct impl *this, struct port *port, uint32_t control_id, float value)
|
||||
{
|
||||
struct v4l2_control c;
|
||||
|
||||
spa_zero(c);
|
||||
c.id = control_id;
|
||||
c.value = value;
|
||||
if (ioctl(port->dev.fd, VIDIOC_S_CTRL, &c) < 0)
|
||||
spa_log_error(this->log, "VIDIOC_S_CTRL %m");
|
||||
}
|
||||
|
||||
static int process_control(struct impl *this, struct spa_pod_sequence *control)
|
||||
{
|
||||
struct spa_pod_control *c;
|
||||
struct port *port;
|
||||
|
||||
SPA_POD_SEQUENCE_FOREACH(control, c) {
|
||||
switch (c->type) {
|
||||
|
|
@ -873,14 +834,7 @@ static int process_control(struct impl *this, struct spa_pod_sequence *control)
|
|||
struct spa_pod_object *obj = (struct spa_pod_object *) &c->value;
|
||||
|
||||
SPA_POD_OBJECT_FOREACH(obj, prop) {
|
||||
uint32_t control_id;
|
||||
|
||||
if ((control_id = prop_to_control_id(prop->key)) == 0)
|
||||
continue;
|
||||
|
||||
port = GET_OUT_PORT(this, 0);
|
||||
set_control(this, port, control_id,
|
||||
SPA_POD_VALUE(struct spa_pod_float, &prop->value));
|
||||
spa_v4l2_set_control(this, prop->key, prop);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue