Skip to content

Commit

Permalink
Handle region bindings accordingly to the running output scaler ports…
Browse files Browse the repository at this point in the history
… on sstar
  • Loading branch information
wberube committed Jun 4, 2024
1 parent b7565d8 commit 2fc7f26
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 44 deletions.
32 changes: 18 additions & 14 deletions src/hal/sstar/i6_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,24 +332,27 @@ int i6_region_create(char handle, hal_rect rect, short opacity)
regionCurr.size.width != region.size.width) {
fprintf(stderr, "[i6_rgn] Parameters are different, recreating "
"region %d...\n", handle);
channel.port = 1;
i6_rgn.fnDetachChannel(handle, &channel);
channel.port = 0;
i6_rgn.fnDetachChannel(handle, &channel);
for (char i = 0; i < I6_VENC_CHN_NUM; i++) {
if (!i6_state[i].enable) continue;
channel.port = i;
i6_rgn.fnDetachChannel(handle, &channel);
}
i6_rgn.fnDestroyRegion(handle);
if (ret = i6_rgn.fnCreateRegion(handle, &region))
return ret;
}

if (i6_rgn.fnGetChannelConfig(handle, &channel, &attribCurr))
fprintf(stderr, "[i6_rgn] Attaching region %d...\n", handle);
else if (attribCurr.point.x != rect.x || attribCurr.point.x != rect.y) {
fprintf(stderr, "[i6_rgn] Position has changed, reattaching "
else if (attribCurr.point.x != rect.x || attribCurr.point.x != rect.y ||
attribCurr.osd.bgFgAlpha[1] != opacity) {
fprintf(stderr, "[i6_rgn] Parameters are different, reattaching "
"region %d...\n", handle);
channel.port = 1;
i6_rgn.fnDetachChannel(handle, &channel);
channel.port = 0;
i6_rgn.fnDetachChannel(handle, &channel);
for (char i = 0; i < I6_VENC_CHN_NUM; i++) {
if (!i6_state[i].enable) continue;
channel.port = i;
i6_rgn.fnDetachChannel(handle, &channel);
}
}

memset(&attrib, 0, sizeof(attrib));
Expand All @@ -361,10 +364,11 @@ int i6_region_create(char handle, hal_rect rect, short opacity)
attrib.osd.bgFgAlpha[0] = 0;
attrib.osd.bgFgAlpha[1] = opacity;

channel.port = 0;
i6_rgn.fnAttachChannel(handle, &channel, &attrib);
channel.port = 1;
i6_rgn.fnAttachChannel(handle, &channel, &attrib);
for (char i = 0; i < I6_VENC_CHN_NUM; i++) {
if (!i6_state[i].enable) continue;
channel.port = i;
i6_rgn.fnAttachChannel(handle, &channel, &attrib);
}

return ret;
}
Expand Down
34 changes: 19 additions & 15 deletions src/hal/sstar/i6c_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,24 +416,27 @@ int i6c_region_create(char handle, hal_rect rect, short opacity)
regionCurr.size.width != region.size.width) {
fprintf(stderr, "[i6c_rgn] Parameters are different, recreating "
"region %d...\n", handle);
channel.port = 1;
i6c_rgn.fnDetachChannel(0, handle, &channel);
channel.port = 0;
i6c_rgn.fnDetachChannel(0, handle, &channel);
for (char i = 0; i < I6C_VENC_CHN_NUM; i++) {
if (!i6c_state[i].enable) continue;
channel.port = i;
i6c_rgn.fnDetachChannel(0, handle, &channel);
}
i6c_rgn.fnDestroyRegion(0, handle);
if (ret = i6c_rgn.fnCreateRegion(0, handle, &region))
return ret;
}

if (i6c_rgn.fnGetChannelConfig(0, handle, &channel, &attribCurr))
fprintf(stderr, "[i6c_rgn] Attaching region %d...\n", handle);
else if (attribCurr.point.x != rect.x || attribCurr.point.x != rect.y) {
fprintf(stderr, "[i6c_rgn] Position has changed, reattaching "
else if (attribCurr.point.x != rect.x || attribCurr.point.x != rect.y ||
attribCurr.osd.bgFgAlpha[1] != opacity) {
fprintf(stderr, "[i6c_rgn] Parameters are different, reattaching "
"region %d...\n", handle);
channel.port = 1;
i6c_rgn.fnDetachChannel(0, handle, &channel);
channel.port = 0;
i6c_rgn.fnDetachChannel(0, handle, &channel);
for (char i = 0; i < I6C_VENC_CHN_NUM; i++) {
if (!i6c_state[i].enable) continue;
channel.port = i;
i6c_rgn.fnDetachChannel(0, handle, &channel);
}
}

memset(&attrib, 0, sizeof(attrib));
Expand All @@ -443,12 +446,13 @@ int i6c_region_create(char handle, hal_rect rect, short opacity)
attrib.osd.layer = 0;
attrib.osd.constAlphaOn = 0;
attrib.osd.bgFgAlpha[0] = 0;
attrib.osd.bgFgAlpha[1] = opacity;
attrib.osd.bgFgAlpha[1] = 255;

channel.port = 0;
i6c_rgn.fnAttachChannel(0, handle, &channel, &attrib);
channel.port = 1;
i6c_rgn.fnAttachChannel(0, handle, &channel, &attrib);
for (char i = 0; i < I6C_VENC_CHN_NUM; i++) {
if (!i6c_state[i].enable) continue;
channel.port = i;
i6c_rgn.fnAttachChannel(0, handle, &channel, &attrib);
}

return ret;
}
Expand Down
32 changes: 18 additions & 14 deletions src/hal/sstar/i6f_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,24 +393,27 @@ int i6f_region_create(char handle, hal_rect rect, short opacity)
regionCurr.size.width != region.size.width) {
fprintf(stderr, "[i6f_rgn] Parameters are different, recreating "
"region %d...\n", handle);
channel.port = 1;
i6f_rgn.fnDetachChannel(0, handle, &channel);
channel.port = 0;
i6f_rgn.fnDetachChannel(0, handle, &channel);
for (char i = 0; i < I6F_VENC_CHN_NUM; i++) {
if (!i6f_state[i].enable) continue;
channel.port = i;
i6f_rgn.fnDetachChannel(0, handle, &channel);
}
i6f_rgn.fnDestroyRegion(0, handle);
if (ret = i6f_rgn.fnCreateRegion(0, handle, &region))
return ret;
}

if (i6f_rgn.fnGetChannelConfig(0, handle, &channel, &attribCurr))
fprintf(stderr, "[i6f_rgn] Attaching region %d...\n", handle);
else if (attribCurr.point.x != rect.x || attribCurr.point.x != rect.y) {
fprintf(stderr, "[i6f_rgn] Position has changed, reattaching "
else if (attribCurr.point.x != rect.x || attribCurr.point.x != rect.y ||
attribCurr.osd.bgFgAlpha[1] != opacity) {
fprintf(stderr, "[i6f_rgn] Parameters are different, reattaching "
"region %d...\n", handle);
channel.port = 1;
i6f_rgn.fnDetachChannel(0, handle, &channel);
channel.port = 0;
i6f_rgn.fnDetachChannel(0, handle, &channel);
for (char i = 0; i < I6F_VENC_CHN_NUM; i++) {
if (!i6f_state[i].enable) continue;
channel.port = i;
i6f_rgn.fnDetachChannel(0, handle, &channel);
}
}

memset(&attrib, 0, sizeof(attrib));
Expand All @@ -422,10 +425,11 @@ int i6f_region_create(char handle, hal_rect rect, short opacity)
attrib.osd.bgFgAlpha[0] = 0;
attrib.osd.bgFgAlpha[1] = opacity;

channel.port = 0;
i6f_rgn.fnAttachChannel(0, handle, &channel, &attrib);
channel.port = 1;
i6f_rgn.fnAttachChannel(0, handle, &channel, &attrib);
for (char i = 0; i < I6F_VENC_CHN_NUM; i++) {
if (!i6f_state[i].enable) continue;
channel.port = i;
i6f_rgn.fnAttachChannel(0, handle, &channel, &attrib);
}

return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ void *server_thread(void *vargp) {
else if (equals(key, "opal")) {
short result = strtol(value, &remain, 10);
if (remain != value)
osds[id].opal = result;
osds[id].opal = result & 0xFF;
}
else if (equals(key, "posx")) {
short result = strtol(value, &remain, 10);
Expand Down

0 comments on commit 2fc7f26

Please sign in to comment.