Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfixes enabling correct values for exposure/vts and gain beeing set. #18

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions raspiraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1621,14 +1621,16 @@ void update_regs(const struct sensor_def *sensor, struct mode_def *mode, int hfl
else
{
uint8_t val;
int i, j=sensor->exposure_reg_num_bits-1;
int i;
int num_regs = (sensor->exposure_reg_num_bits+7)>>3;
int bit_end = (sensor->exposure_reg_num_bits-1) & 0x7;

for(i=0; i<num_regs; i++, j-=8)
for(i=0; i<num_regs; i++)
{
val = (exposure >> (j&~7)) & 0xFF;
modReg(mode, sensor->exposure_reg+i, 0, j&0x7, val, EQUAL);
val = (exposure >> (8*(num_regs-1-i))) & 0xFF;
modReg(mode, sensor->exposure_reg+i, 0, bit_end, val, EQUAL);
vcos_log_error("Set exposure %04X to %02X", sensor->exposure_reg+i, val);
bit_end = 0x07;
}
}
}
Expand All @@ -1642,14 +1644,16 @@ void update_regs(const struct sensor_def *sensor, struct mode_def *mode, int hfl
else
{
uint8_t val;
int i, j=sensor->vts_reg_num_bits-1;
int i;
int num_regs = (sensor->vts_reg_num_bits+7)>>3;
int bit_end = (sensor->vts_reg_num_bits-1) & 0x7;

for(i = 0; i<num_regs; i++, j-=8)
for(i = 0; i<num_regs; i++)
{
val = (exposure >> (j&~7)) & 0xFF;
modReg(mode, sensor->vts_reg+i, 0, j&0x7, val, EQUAL);
val = (exposure >> (8*(num_regs-1-i))) & 0xFF;
modReg(mode, sensor->vts_reg+i, 0, bit_end, val, EQUAL);
vcos_log_error("Set vts %04X to %02X", sensor->vts_reg+i, val);
bit_end = 0x07;
}
}
}
Expand All @@ -1663,14 +1667,16 @@ void update_regs(const struct sensor_def *sensor, struct mode_def *mode, int hfl
else
{
uint8_t val;
int i, j=sensor->gain_reg_num_bits-1;
int i;
int num_regs = (sensor->gain_reg_num_bits+7)>>3;
int bit_end = (sensor->gain_reg_num_bits-1) & 0x7;

for(i = 0; i<num_regs; i++, j-=8)
for(i = 0; i<num_regs; i++)
{
val = (gain >> (j&~7)) & 0xFF;
modReg(mode, sensor->gain_reg+i, 0, j&0x7, val, EQUAL);
val = (gain >> (8*(num_regs-1-i))) & 0xFF;
modReg(mode, sensor->gain_reg+i, 0, bit_end, val, EQUAL);
vcos_log_error("Set gain %04X to %02X", sensor->gain_reg+i, val);
bit_end = 0x07;
}
}
}
Expand Down