Skip to content

Commit

Permalink
drivers: media: cfe: Don't confuse MHz and Mbps
Browse files Browse the repository at this point in the history
The driver was interchaning these units when talking about link rate.
Fix this to avoid confusion. Apart from the logging message change,
there is no function change in this commit.

Signed-off-by: Naushir Patuck <[email protected]>
  • Loading branch information
naushir authored and popcornmix committed Nov 21, 2023
1 parent b35e135 commit d26ea41
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions drivers/media/platform/raspberrypi/rp1_cfe/cfe.c
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ static void cfe_buffer_queue(struct vb2_buffer *vb)
spin_unlock_irqrestore(&cfe->state_lock, flags);
}

static u64 sensor_link_frequency(struct cfe_device *cfe)
static u64 sensor_link_rate(struct cfe_device *cfe)
{
struct v4l2_mbus_framefmt *source_fmt;
struct v4l2_subdev_state *state;
Expand Down Expand Up @@ -1028,11 +1028,11 @@ static u64 sensor_link_frequency(struct cfe_device *cfe)

/* x2 for DDR. */
link_freq *= 2;
cfe_info("Using a link frequency of %lld Hz\n", link_freq);
cfe_info("Using a link rate of %lld Mbps\n", link_freq / (1000 * 1000));
return link_freq;

err:
cfe_err("Unable to determine sensor link frequency, using 999 MHz\n");
cfe_err("Unable to determine sensor link rate, using 999 Mbps\n");
return 999 * 1000000UL;
}

Expand Down Expand Up @@ -1104,7 +1104,7 @@ static int cfe_start_streaming(struct vb2_queue *vq, unsigned int count)
}

cfe_dbg("Configuring CSI-2 block\n");
cfe->csi2.dphy.dphy_freq = sensor_link_frequency(cfe) / 1000000UL;
cfe->csi2.dphy.dphy_rate = sensor_link_rate(cfe) / 1000000UL;
csi2_open_rx(&cfe->csi2);

cfe_dbg("Starting sensor streaming\n");
Expand Down
10 changes: 5 additions & 5 deletions drivers/media/platform/raspberrypi/rp1_cfe/dphy.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static uint8_t dphy_transaction(struct dphy_data *dphy, u8 test_code,
return get_tstdout(dphy);
}

static void dphy_set_hsfreqrange(struct dphy_data *dphy, uint32_t freq_mhz)
static void dphy_set_hsfreqrange(struct dphy_data *dphy, uint32_t mbps)
{
/* See Table 5-1 on page 65 of dphy databook */
static const u16 hsfreqrange_table[][2] = {
Expand All @@ -116,11 +116,11 @@ static void dphy_set_hsfreqrange(struct dphy_data *dphy, uint32_t freq_mhz)
};
unsigned int i;

if (freq_mhz < 80 || freq_mhz > 1500)
dphy_err("DPHY: Frequency %u MHz out of range\n", freq_mhz);
if (mbps < 80 || mbps > 1500)
dphy_err("DPHY: Datarate %u Mbps out of range\n", mbps);

for (i = 0; i < ARRAY_SIZE(hsfreqrange_table) - 1; i++) {
if (freq_mhz <= hsfreqrange_table[i][0])
if (mbps <= hsfreqrange_table[i][0])
break;
}

Expand All @@ -139,7 +139,7 @@ static void dphy_init(struct dphy_data *dphy)
set_tstclr(dphy, 0);
usleep_range(15, 20);

dphy_set_hsfreqrange(dphy, dphy->dphy_freq);
dphy_set_hsfreqrange(dphy, dphy->dphy_rate);

usleep_range(5, 10);
dw_csi2_host_write(dphy, PHY_SHUTDOWNZ, 1);
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/platform/raspberrypi/rp1_cfe/dphy.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct dphy_data {

void __iomem *base;

u32 dphy_freq;
u32 dphy_rate;
u32 num_lanes;
};

Expand Down

0 comments on commit d26ea41

Please sign in to comment.