/* Don't accept a code that is not on the debayer table */
vpix = vimc_debayer_pix_map_by_code(fmt->code); if (!vpix)
fmt->code = sink_fmt_default.code;
/* Do not change the format while stream is on. */ if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE && vdebayer->src_frame) return -EBUSY;
/* * Do not change the format of the source pad, it is propagated from * the sink.
*/ if (VIMC_IS_SRC(fmt->pad)) return v4l2_subdev_get_fmt(sd, sd_state, fmt);
/* Set the new format in the sink pad. */
vimc_debayer_adjust_sink_fmt(&fmt->format);
format = v4l2_subdev_state_get_format(sd_state, 0);
/* Propagate the format to the source pad. */
format = v4l2_subdev_state_get_format(sd_state, 1);
*format = fmt->format;
format->code = VIMC_DEBAYER_SOURCE_MBUS_FMT;
/* Calculate the frame size of the source pad */
vpix = vimc_pix_map_by_code(src_fmt->code);
frame_size = src_fmt->width * src_fmt->height * vpix->bpp;
/* Save the bytes per pixel of the sink */
vpix = vimc_pix_map_by_code(sink_fmt->code);
vdebayer->hw.sink_bpp = vpix->bpp;
/* Get the corresponding pixel map from the table */
vdebayer->hw.sink_pix_map =
vimc_debayer_pix_map_by_code(sink_fmt->code);
/* * Allocate the frame buffer. Use vmalloc to be able to * allocate a large amount of memory
*/
vdebayer->src_frame = vmalloc(frame_size); if (!vdebayer->src_frame) return -ENOMEM;
} else { if (!vdebayer->src_frame) return0;
/* * Calculate how many we need to subtract to get to the pixel in * the top left corner of the mean window (considering the current * pixel as the center)
*/
seek = vdebayer->hw.mean_win_size / 2;
/* Sum the values of the colors in the mean window */
/* * Iterate through all the lines in the mean window, start * with zero if the pixel is outside the frame and don't pass * the height when the pixel is in the bottom border of the * frame
*/ for (wlin = seek > lin ? 0 : lin - seek;
wlin < lin + seek + 1 && wlin < vdebayer->hw.size.height;
wlin++) {
/* * Iterate through all the columns in the mean window, start * with zero if the pixel is outside the frame and don't pass * the width when the pixel is in the right border of the * frame
*/ for (wcol = seek > col ? 0 : col - seek;
wcol < col + seek + 1 && wcol < vdebayer->hw.size.width;
wcol++) { enum vimc_debayer_rgb_colors color; unsignedint index;
/* Check which color this pixel is */
color = vdebayer->hw.sink_pix_map->order[wlin % 2][wcol % 2];
index = VIMC_FRAME_INDEX(wlin, wcol,
vdebayer->hw.size.width,
vdebayer->hw.sink_bpp);
dev_dbg(vdebayer->ved.dev, "deb: %s: RGB CALC: frame index %d, win pos %dx%d, color %d\n",
vdebayer->sd.name, index, wlin, wcol, color);
/* Get its value */
rgb[color] = rgb[color] +
vimc_debayer_get_val(&frame[index],
vdebayer->hw.sink_bpp);
/* Save how many values we already added */
n_rgb[color]++;
dev_dbg(vdebayer->ved.dev, "deb: %s: RGB CALC: val %d, n %d\n",
vdebayer->sd.name, rgb[color], n_rgb[color]);
}
}
/* Calculate the mean */ for (i = 0; i < 3; i++) {
dev_dbg(vdebayer->ved.dev, "deb: %s: PRE CALC: %dx%d Color %d, val %d, n %d\n",
vdebayer->sd.name, lin, col, i, rgb[i], n_rgb[i]);
if (n_rgb[i])
rgb[i] = rgb[i] / n_rgb[i];
dev_dbg(vdebayer->ved.dev, "deb: %s: FINAL CALC: %dx%d Color %d, val %d\n",
vdebayer->sd.name, lin, col, i, rgb[i]);
}
}
/* If the stream in this node is not active, just return */ if (!vdebayer->src_frame) return ERR_PTR(-EINVAL);
for (i = 0; i < vdebayer->hw.size.height; i++) for (j = 0; j < vdebayer->hw.size.width; j++) {
vimc_debayer_calc_rgb_sink(vdebayer, sink_frame, i, j, rgb);
vdebayer->set_rgb_src(vdebayer, i, j, rgb);
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.14Bemerkung:
(vorverarbeitet am 2026-06-07)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.