桥接IC lt7911d linux 驱动

lt7911d C 代码
// SPDX-License-Identifier: GPL-2.0
/*

  • Copyright © 2021 Rockchip Electronics Co. Ltd.
  • lt7911d type-c/DP to MIPI CSI-2 bridge driver.
  • V0.0X01.0X00 first version.
  • V0.0X01.0X01 add 4K30 support.
  • V0.0X01.0X02 add poll resolution change.

*/

#define LT7911D_CHIPID 0x0516
#define CHIPID_REGH 0xA001
#define CHIPID_REGL 0xA000
#define I2C_EN_REG 0x80EE
#define I2C_ENABLE 0x1
#define I2C_DISABLE 0x0

#define AD_HALF_PIX_CLK 0x21
#define SOURCE_DP_RX 0x10
#define RECEIVED_INT 1

#define HTOTAL_H 0xd289
#define HTOTAL_L 0xd28a
#define HACT_H 0xd28b
#define HACT_L 0xd28c
#define HFP_H 0xd29c
#define HFP_L 0xd29d
#define HS_H 0xd294
#define HS_L 0xd295
#define HBP_H 0xd298
#define HBP_L 0xd299

#define VTOTAL_H 0xd29e
#define VTOTAL_L 0xd29f
#define VACT_H 0xd296
#define VACT_L 0xd297
#define VBP 0xd287
#define VFP 0xd288
#define VS 0xd286

#define FM_CLK_SEL 0xa034
#define FREQ_METER_H 0xb8b1
#define FREQ_METER_M 0xb8b2
#define FREQ_METER_L 0xb8b3
#define RG_MK_PRESET_SEL 0xd283

#define STREAM_CTL 0x900a
#define ENABLE_STREAM 0xbf
#define DISABLE_STREAM 0xbe

#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/hdmi.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of_graph.h>
#include <linux/rk-camera-module.h>
#include <linux/slab.h>
#include <linux/timer.h>
#include <linux/v4l2-dv-timings.h>
#include <linux/version.h>
#include <linux/videodev2.h>
#include <linux/workqueue.h>
#include <linux/compat.h>
#include <media/v4l2-controls_rockchip.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-device.h>
#include <media/v4l2-dv-timings.h>
#include <media/v4l2-event.h>
#include <media/v4l2-fwnode.h>
#include “lt7911d.h”

#define DRIVER_VERSION KERNEL_VERSION(0, 0x01, 0x02)

static int debug;
module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, “debug level (0-3)”);

#define I2C_MAX_XFER_SIZE 128
#define POLL_INTERVAL_MS 1000

#define LT7911D_LINK_FREQ 400000000
#define LT7911D_PIXEL_RATE 400000000

#define LT7911D_NAME “LT7911D”

static const s64 link_freq_menu_items[] = {
LT7911D_LINK_FREQ,
};

struct lt7911d_state {
struct v4l2_fwnode_bus_mipi_csi2 bus;
struct v4l2_subdev sd;
struct media_pad pad;
struct v4l2_ctrl_handler hdl;
struct i2c_client *i2c_client;
struct mutex confctl_mutex;
struct v4l2_ctrl *detect_tx_5v_ctrl;
struct v4l2_ctrl *audio_sampling_rate_ctrl;
struct v4l2_ctrl *audio_present_ctrl;
struct v4l2_ctrl *link_freq;
struct v4l2_ctrl *pixel_rate;
struct delayed_work delayed_work_enable_hotplug;
struct delayed_work delayed_work_res_change;
struct v4l2_dv_timings timings;
struct clk *xvclk;
struct gpio_desc *reset_gpio;
struct gpio_desc *plugin_det_gpio;
struct gpio_desc *power_gpio;
struct work_struct work_i2c_poll;
struct timer_list timer;
const char *module_facing;
const char *module_name;
const char *len_name;
const struct lt7911d_mode *cur_mode;
bool nosignal;
bool enable_hdcp;
bool is_audio_present;
int plugin_irq;
u32 mbus_fmt_code;
u8 csi_lanes_in_use;
u32 module_index;
u32 audio_sampling_rate;
};

static const struct v4l2_dv_timings_cap lt7911d_timings_cap = {
.type = V4L2_DV_BT_656_1120,
.reserved = { 0 },
V4L2_INIT_BT_TIMINGS(1, 10000, 1, 10000, 0, 400000000,
V4L2_DV_BT_STD_CEA861 | V4L2_DV_BT_STD_DMT |
V4L2_DV_BT_STD_GTF | V4L2_DV_BT_STD_CVT,
V4L2_DV_BT_CAP_PROGRESSIVE | V4L2_DV_BT_CAP_INTERLACED |
V4L2_DV_BT_CAP_REDUCED_BLANKING |
V4L2_DV_BT_CAP_CUSTOM)
};

struct lt7911d_mode {
u32 width;
u32 height;
struct v4l2_fract max_fps;
u32 hts_def;
u32 vts_def;
u32 exp_def;
};

static const struct lt7911d_mode supported_modes[] = {
{
.width = 3840,
.height = 2160,
.max_fps = {
.numerator = 10000,
.denominator = 300000,
},
.hts_def = 4400,
.vts_def = 2250,
}, {
.width = 1920,
.height = 1080,
.max_fps = {
.numerator = 10000,
.denominator = 600000,
},
.hts_def = 2200,
.vts_def = 1125,
}, {
.width = 1280,
.height = 720,
.max_fps = {
.numerator = 10000,
.denominator = 600000,
},
.hts_def = 1650,
.vts_def = 750,
}, {
.width = 720,
.height = 576,
.max_fps = {
.numerator = 10000,
.denominator = 500000,
},
.hts_def = 864,
.vts_def = 625,
}, {
.width = 720,
.height = 480,
.max_fps = {
.numerator = 10000,
.denominator = 600000,
},
.hts_def = 858,
.vts_def = 525,
},
};

static void lt7911d_format_change(struct v4l2_subdev *sd);
static int lt7911d_s_ctrl_detect_tx_5v(struct v4l2_subdev *sd);
static int lt7911d_s_dv_timings(struct v4l2_subdev *sd,
struct v4l2_dv_timings *timings);

static inline struct lt7911d_state *to_state(struct v4l2_subdev *sd)
{
return container_of(sd, struct lt7911d_state, sd);
}

static void i2c_rd(struct v4l2_subdev *sd, u16 reg, u8 *values, u32 n)
{
struct lt7911d_state *lt7911d = to_state(sd);
struct i2c_client *client = lt7911d->i2c_client;
int err;
u8 buf[2] = { 0xFF, reg >> 8};
u8 reg_addr = reg & 0xFF;
struct i2c_msg msgs[3];

msgs[0].addr = client->addr;
msgs[0].flags = 0;
msgs[0].len = 2;
msgs[0].buf = buf;msgs[1].addr = client->addr;
msgs[1].flags = 0;
msgs[1].len = 1;
msgs[1].buf = &reg_addr;msgs[2].addr = client->addr;
msgs[2].flags = I2C_M_RD;
msgs[2].len = n;
msgs[2].buf = values;err = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
if (err != ARRAY_SIZE(msgs)) {v4l2_err(sd, "%s: reading register 0x%x from 0x%x failed\n",__func__, reg, client->addr);
}if (!debug)return;switch (n) {
case 1:v4l2_info(sd, "I2C read 0x%04x = 0x%02x\n",reg, values[0]);break;
case 2:v4l2_info(sd, "I2C read 0x%04x = 0x%02x%02x\n",reg, values[1], values[0]);break;
case 4:v4l2_info(sd, "I2C read 0x%04x = 0x%02x%02x%02x%02x\n",reg, values[3], values[2], values[1], values[0]);break;
default:v4l2_info(sd, "I2C read %d bytes from address 0x%04x\n",n, reg);
}

}

static void i2c_wr(struct v4l2_subdev *sd, u16 reg, u8 *values, u32 n)
{
struct lt7911d_state *lt7911d = to_state(sd);
struct i2c_client *client = lt7911d->i2c_client;
int err, i;
struct i2c_msg msgs[2];
u8 data[I2C_MAX_XFER_SIZE];
u8 buf[2] = { 0xFF, reg >> 8};

if ((1 + n) > I2C_MAX_XFER_SIZE) {n = I2C_MAX_XFER_SIZE - 1;v4l2_warn(sd, "i2c wr reg=%04x: len=%d is too big!\n",reg, 1 + n);
}msgs[0].addr = client->addr;
msgs[0].flags = 0;
msgs[0].len = 2;
msgs[0].buf = buf;msgs[1].addr = client->addr;
msgs[1].flags = 0;
msgs[1].len = 1 + n;
msgs[1].buf = data;data[0] = reg & 0xff;
for (i = 0; i < n; i++)data[1 + i] = values[i];err = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
if (err < 0) {v4l2_err(sd, "%s: writing register 0x%x from 0x%x failed\n",__func__, reg, client->addr);return;
}if (!debug)return;switch (n) {
case 1:v4l2_info(sd, "I2C write 0x%04x = 0x%02x\n",reg, data[1]);break;
case 2:v4l2_info(sd, "I2C write 0x%04x = 0x%02x%02x\n",reg, data[2], data[1]);break;
case 4:v4l2_info(sd, "I2C write 0x%04x = 0x%02x%02x%02x%02x\n",reg, data[4], data[3], data[2], data[1]);break;
default:v4l2_info(sd, "I2C write %d bytes from address 0x%04x\n",n, reg);
}

}

static u8 i2c_rd8(struct v4l2_subdev *sd, u16 reg)
{
u32 val;

i2c_rd(sd, reg, (u8 __force *)&val, 1);
return val;

}

static void i2c_wr8(struct v4l2_subdev *sd, u16 reg, u8 val)
{
i2c_wr(sd, reg, &val, 1);
}

static void lt7911d_i2c_enable(struct v4l2_subdev *sd)
{
i2c_wr8(sd, I2C_EN_REG, I2C_ENABLE);
}

static void lt7911d_i2c_disable(struct v4l2_subdev *sd)
{
i2c_wr8(sd, I2C_EN_REG, I2C_DISABLE);
}

static inline bool tx_5v_power_present(struct v4l2_subdev *sd)
{
bool ret;
int val, i, cnt;
struct lt7911d_state *lt7911d = to_state(sd);

/* if not use plugin det gpio */
if (!lt7911d->plugin_det_gpio)return true;cnt = 0;
for (i = 0; i < 5; i++) {val = gpiod_get_value(lt7911d->plugin_det_gpio);if (val > 0)cnt++;usleep_range(500, 600);
}ret = (cnt >= 3) ? true : false;
v4l2_dbg(1, debug, sd, "%s: %d\n", __func__, ret);return ret;

}

static inline bool no_signal(struct v4l2_subdev *sd)
{
struct lt7911d_state *lt7911d = to_state(sd);

v4l2_dbg(1, debug, sd, "%s no signal:%d\n", __func__,lt7911d->nosignal);return lt7911d->nosignal;

}

static inline bool audio_present(struct v4l2_subdev *sd)
{
struct lt7911d_state *lt7911d = to_state(sd);

return lt7911d->is_audio_present;

}

static int get_audio_sampling_rate(struct v4l2_subdev *sd)
{
static const int code_to_rate[] = {
44100, 0, 48000, 32000, 22050, 384000, 24000, 352800,
88200, 768000, 96000, 705600, 176400, 0, 192000, 0
};

if (no_signal(sd))return 0;return code_to_rate[2];

}

static inline unsigned int fps_calc(const struct v4l2_bt_timings *t)
{
if (!V4L2_DV_BT_FRAME_HEIGHT(t) || !V4L2_DV_BT_FRAME_WIDTH(t))
return 0;

return DIV_ROUND_CLOSEST((unsigned int)t->pixelclock,V4L2_DV_BT_FRAME_HEIGHT(t) * V4L2_DV_BT_FRAME_WIDTH(t));

}

static bool lt7911d_rcv_supported_res(struct v4l2_subdev *sd, u32 width,
u32 height)
{
u32 i;

for (i = 0; i < ARRAY_SIZE(supported_modes); i++) {if ((supported_modes[i].width == width) &&(supported_modes[i].height == height)) {break;}
}if (i == ARRAY_SIZE(supported_modes)) {v4l2_err(sd, "%s do not support res wxh: %dx%d\n", __func__,width, height);return false;
} else {return true;
}

}

static int lt7911d_get_detected_timings(struct v4l2_subdev *sd,
struct v4l2_dv_timings *timings)
{
struct lt7911d_state *lt7911d = to_state(sd);
struct v4l2_bt_timings *bt = &timings->bt;
u32 hact, vact, htotal, vtotal;
u32 hbp, hs, hfp, vbp, vs, vfp;
u32 pixel_clock, fps, halt_pix_clk;
u8 clk_h, clk_m, clk_l;
u8 value, val_h, val_l;

memset(timings, 0, sizeof(struct v4l2_dv_timings));lt7911d_i2c_enable(sd);
i2c_wr8(sd, FM_CLK_SEL, AD_HALF_PIX_CLK);
mdelay(10);
clk_h = i2c_rd8(sd, FREQ_METER_H);
clk_m = i2c_rd8(sd, FREQ_METER_M);
clk_l = i2c_rd8(sd, FREQ_METER_L);
halt_pix_clk = (((clk_h & 0xf) << 16) | (clk_m << 8) | clk_l);
pixel_clock = halt_pix_clk * 2 * 1000;i2c_wr8(sd, RG_MK_PRESET_SEL, SOURCE_DP_RX);
mdelay(10);
val_h = i2c_rd8(sd, HTOTAL_H);
val_l = i2c_rd8(sd, HTOTAL_L);
htotal = ((val_h << 8) | val_l) * 2;
val_h = i2c_rd8(sd, VTOTAL_H);
val_l = i2c_rd8(sd, VTOTAL_L);
vtotal = (val_h << 8) | val_l;
val_h = i2c_rd8(sd, HACT_H);
val_l = i2c_rd8(sd, HACT_L);
hact = ((val_h << 8) | val_l) * 2;
val_h = i2c_rd8(sd, VACT_H);
val_l = i2c_rd8(sd, VACT_L);
vact = (val_h << 8) | val_l;
val_h = i2c_rd8(sd, HS_H);
val_l = i2c_rd8(sd, HS_L);
hs = ((val_h << 8) | val_l) * 2;
value = i2c_rd8(sd, VS);
vs = value;
val_h = i2c_rd8(sd, HFP_H);
val_l = i2c_rd8(sd, HFP_L);
hfp = ((val_h << 8) | val_l) * 2;
value = i2c_rd8(sd, VFP);
vfp = value;
val_h = i2c_rd8(sd, HBP_H);
val_l = i2c_rd8(sd, HBP_L);
hbp = ((val_h << 8) | val_l) * 2;
value = i2c_rd8(sd, VBP);
vbp = value;lt7911d_i2c_disable(sd);if (!lt7911d_rcv_supported_res(sd, hact, vact)) {lt7911d->nosignal = true;v4l2_err(sd, "%s: rcv err res, return no signal!\n", __func__);return -EINVAL;
}lt7911d->nosignal = false;
lt7911d->is_audio_present = true;
timings->type = V4L2_DV_BT_656_1120;
bt->interlaced = V4L2_DV_PROGRESSIVE;
bt->width = hact;
bt->height = vact;
bt->vsync = vs;
bt->hsync = hs;
bt->pixelclock = pixel_clock;
bt->hfrontporch = hfp;
bt->vfrontporch = vfp;
bt->hbackporch = hbp;
bt->vbackporch = vbp;
fps = fps_calc(bt);v4l2_info(sd, "act:%dx%d, total:%dx%d, pixclk:%d, fps:%d\n",hact, vact, htotal, vtotal, pixel_clock, fps);
v4l2_info(sd, "hfp:%d, hs:%d, hbp:%d, vfp:%d, vs:%d, vbp:%d\n",bt->hfrontporch, bt->hsync, bt->hbackporch,bt->vfrontporch, bt->vsync, bt->vbackporch);
v4l2_info(sd, "inerlaced:%d,\n", bt->interlaced);return 0;

}

static void lt7911d_delayed_work_enable_hotplug(struct work_struct *work)
{
struct delayed_work *dwork = to_delayed_work(work);
struct lt7911d_state *lt7911d = container_of(dwork,
struct lt7911d_state, delayed_work_enable_hotplug);
struct v4l2_subdev *sd = &lt7911d->sd;

v4l2_ctrl_s_ctrl(lt7911d->detect_tx_5v_ctrl, tx_5v_power_present(sd));

}

static void lt7911d_delayed_work_res_change(struct work_struct *work)
{
struct delayed_work *dwork = to_delayed_work(work);
struct lt7911d_state *lt7911d = container_of(dwork,
struct lt7911d_state, delayed_work_res_change);
struct v4l2_subdev *sd = &lt7911d->sd;

lt7911d_format_change(sd);

}

static int lt7911d_s_ctrl_detect_tx_5v(struct v4l2_subdev *sd)
{
struct lt7911d_state *lt7911d = to_state(sd);

return v4l2_ctrl_s_ctrl(lt7911d->detect_tx_5v_ctrl,tx_5v_power_present(sd));

}

static int lt7911d_s_ctrl_audio_sampling_rate(struct v4l2_subdev *sd)
{
struct lt7911d_state *lt7911d = to_state(sd);

return v4l2_ctrl_s_ctrl(lt7911d->audio_sampling_rate_ctrl,get_audio_sampling_rate(sd));

}

static int lt7911d_s_ctrl_audio_present(struct v4l2_subdev *sd)
{
struct lt7911d_state *lt7911d = to_state(sd);

return v4l2_ctrl_s_ctrl(lt7911d->audio_present_ctrl,audio_present(sd));

}

static int lt7911d_update_controls(struct v4l2_subdev *sd)
{
int ret = 0;

ret |= lt7911d_s_ctrl_detect_tx_5v(sd);
ret |= lt7911d_s_ctrl_audio_sampling_rate(sd);
ret |= lt7911d_s_ctrl_audio_present(sd);return ret;

}

static inline void enable_stream(struct v4l2_subdev *sd, bool enable)
{
v4l2_dbg(2, debug, sd, “%s: %sable\n”,
func, enable ? “en” : “dis”);
}

static void lt7911d_format_change(struct v4l2_subdev *sd)
{
struct lt7911d_state *lt7911d = to_state(sd);
struct v4l2_dv_timings timings;
const struct v4l2_event lt7911d_ev_fmt = {
.type = V4L2_EVENT_SOURCE_CHANGE,
.u.src_change.changes = V4L2_EVENT_SRC_CH_RESOLUTION,
};

if (lt7911d_get_detected_timings(sd, &timings)) {enable_stream(sd, false);v4l2_dbg(1, debug, sd, "%s: No signal\n", __func__);
} else {if (!v4l2_match_dv_timings(&lt7911d->timings, &timings, 0, false)) {enable_stream(sd, false);/* automatically set timing rather than set by user */lt7911d_s_dv_timings(sd, &timings);v4l2_print_dv_timings(sd->name,"Format_change: New format: ",&timings, false);}
}if (sd->devnode)v4l2_subdev_notify_event(sd, &lt7911d_ev_fmt);

}

static int lt7911d_isr(struct v4l2_subdev *sd, u32 status, bool *handled)
{
struct lt7911d_state *lt7911d = to_state(sd);

schedule_delayed_work(&lt7911d->delayed_work_res_change, HZ / 20);
*handled = true;return 0;

}

static irqreturn_t lt7911d_res_change_irq_handler(int irq, void *dev_id)
{
struct lt7911d_state *lt7911d = dev_id;
bool handled;

lt7911d_isr(&lt7911d->sd, 0, &handled);return handled ? IRQ_HANDLED : IRQ_NONE;

}

static irqreturn_t plugin_detect_irq_handler(int irq, void *dev_id)
{
struct lt7911d_state *lt7911d = dev_id;

/* control hpd output level after 25ms */
schedule_delayed_work(&lt7911d->delayed_work_enable_hotplug,HZ / 40);return IRQ_HANDLED;

}

static void lt7911d_irq_poll_timer(struct timer_list *t)
{
struct lt7911d_state *lt7911d = from_timer(lt7911d, t, timer);

schedule_work(&lt7911d->work_i2c_poll);
mod_timer(&lt7911d->timer, jiffies + msecs_to_jiffies(POLL_INTERVAL_MS));

}

static void lt7911d_work_i2c_poll(struct work_struct *work)
{
struct lt7911d_state *lt7911d = container_of(work,
struct lt7911d_state, work_i2c_poll);
struct v4l2_subdev *sd = &lt7911d->sd;

lt7911d_format_change(sd);

}

static int lt7911d_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
struct v4l2_event_subscription *sub)
{
switch (sub->type) {
case V4L2_EVENT_SOURCE_CHANGE:
return v4l2_src_change_event_subdev_subscribe(sd, fh, sub);
case V4L2_EVENT_CTRL:
return v4l2_ctrl_subdev_subscribe_event(sd, fh, sub);
default:
return -EINVAL;
}
}

static int lt7911d_g_input_status(struct v4l2_subdev *sd, u32 *status)
{
*status = 0;
*status |= no_signal(sd) ? V4L2_IN_ST_NO_SIGNAL : 0;

v4l2_dbg(1, debug, sd, "%s: status = 0x%x\n", __func__, *status);return 0;

}

static int lt7911d_s_dv_timings(struct v4l2_subdev *sd,
struct v4l2_dv_timings *timings)
{
struct lt7911d_state *lt7911d = to_state(sd);

if (!timings)return -EINVAL;if (debug)v4l2_print_dv_timings(sd->name, "s_dv_timings: ",timings, false);if (v4l2_match_dv_timings(&lt7911d->timings, timings, 0, false)) {v4l2_dbg(1, debug, sd, "%s: no change\n", __func__);return 0;
}if (!v4l2_valid_dv_timings(timings,&lt7911d_timings_cap, NULL, NULL)) {v4l2_dbg(1, debug, sd, "%s: timings out of range\n", __func__);return -ERANGE;
}lt7911d->timings = *timings;enable_stream(sd, false);return 0;

}

static int lt7911d_g_dv_timings(struct v4l2_subdev *sd,
struct v4l2_dv_timings *timings)
{
struct lt7911d_state *lt7911d = to_state(sd);

*timings = lt7911d->timings;return 0;

}

static int lt7911d_enum_dv_timings(struct v4l2_subdev *sd,
struct v4l2_enum_dv_timings *timings)
{
if (timings->pad != 0)
return -EINVAL;

return v4l2_enum_dv_timings_cap(timings,&lt7911d_timings_cap, NULL, NULL);

}

static int lt7911d_query_dv_timings(struct v4l2_subdev *sd,
struct v4l2_dv_timings *timings)
{
struct lt7911d_state *lt7911d = to_state(sd);

*timings = lt7911d->timings;
if (debug)v4l2_print_dv_timings(sd->name,"query_dv_timings: ", timings, false);if (!v4l2_valid_dv_timings(timings, &lt7911d_timings_cap, NULL,NULL)) {v4l2_dbg(1, debug, sd, "%s: timings out of range\n",__func__);return -ERANGE;
}return 0;

}

static int lt7911d_dv_timings_cap(struct v4l2_subdev *sd,
struct v4l2_dv_timings_cap *cap)
{
if (cap->pad != 0)
return -EINVAL;

*cap = lt7911d_timings_cap;return 0;

}

static int lt7911d_g_mbus_config(struct v4l2_subdev *sd,
unsigned int pad, struct v4l2_mbus_config *cfg)
{
struct lt7911d_state *lt7911d = to_state(sd);

cfg->type = V4L2_MBUS_CSI2_DPHY;
cfg->flags = V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK |V4L2_MBUS_CSI2_CHANNEL_0;switch (lt7911d->csi_lanes_in_use) {
case 1:cfg->flags |= V4L2_MBUS_CSI2_1_LANE;break;
case 2:cfg->flags |= V4L2_MBUS_CSI2_2_LANE;break;
case 3:cfg->flags |= V4L2_MBUS_CSI2_3_LANE;break;
case 4:cfg->flags |= V4L2_MBUS_CSI2_4_LANE;break;default:return -EINVAL;
}return 0;

}

static int lt7911d_s_stream(struct v4l2_subdev *sd, int enable)
{
enable_stream(sd, enable);

return 0;

}

static int lt7911d_enum_mbus_code(struct v4l2_subdev *sd,
struct v4l2_subdev_pad_config *cfg,
struct v4l2_subdev_mbus_code_enum *code)
{
switch (code->index) {
case 0:
code->code = MEDIA_BUS_FMT_UYVY8_2X8;
break;

default:return -EINVAL;
}return 0;

}

static int lt7911d_enum_frame_sizes(struct v4l2_subdev *sd,
struct v4l2_subdev_pad_config *cfg,
struct v4l2_subdev_frame_size_enum *fse)
{
if (fse->index >= ARRAY_SIZE(supported_modes))
return -EINVAL;

if (fse->code != MEDIA_BUS_FMT_UYVY8_2X8)return -EINVAL;fse->min_width  = supported_modes[fse->index].width;
fse->max_width  = supported_modes[fse->index].width;
fse->max_height = supported_modes[fse->index].height;
fse->min_height = supported_modes[fse->index].height;return 0;

}

static int lt7911d_get_fmt(struct v4l2_subdev *sd,
struct v4l2_subdev_pad_config *cfg,
struct v4l2_subdev_format *format)
{
struct lt7911d_state *lt7911d = to_state(sd);

mutex_lock(&lt7911d->confctl_mutex);
format->format.code = lt7911d->mbus_fmt_code;
format->format.width = lt7911d->timings.bt.width;
format->format.height = lt7911d->timings.bt.height;
format->format.field =lt7911d->timings.bt.interlaced ?V4L2_FIELD_INTERLACED : V4L2_FIELD_NONE;
format->format.colorspace = V4L2_COLORSPACE_SRGB;
mutex_unlock(&lt7911d->confctl_mutex);v4l2_dbg(1, debug, sd, "%s: fmt code:%d, w:%d, h:%d, field code:%d\n",__func__, format->format.code, format->format.width,format->format.height, format->format.field);return 0;

}

static int lt7911d_enum_frame_interval(struct v4l2_subdev *sd,
struct v4l2_subdev_pad_config *cfg,
struct v4l2_subdev_frame_interval_enum *fie)
{
if (fie->index >= ARRAY_SIZE(supported_modes))
return -EINVAL;

if (fie->code != MEDIA_BUS_FMT_UYVY8_2X8)return -EINVAL;fie->width = supported_modes[fie->index].width;
fie->height = supported_modes[fie->index].height;
fie->interval = supported_modes[fie->index].max_fps;return 0;

}

static int lt7911d_get_reso_dist(const struct lt7911d_mode *mode,
struct v4l2_mbus_framefmt *framefmt)
{
return abs(mode->width - framefmt->width) +
abs(mode->height - framefmt->height);
}

static const struct lt7911d_mode *
lt7911d_find_best_fit(struct v4l2_subdev_format *fmt)
{
struct v4l2_mbus_framefmt *framefmt = &fmt->format;
int dist;
int cur_best_fit = 0;
int cur_best_fit_dist = -1;
unsigned int i;

for (i = 0; i < ARRAY_SIZE(supported_modes); i++) {dist = lt7911d_get_reso_dist(&supported_modes[i], framefmt);if (cur_best_fit_dist == -1 || dist < cur_best_fit_dist) {cur_best_fit_dist = dist;cur_best_fit = i;}
}return &supported_modes[cur_best_fit];

}

static int lt7911d_set_fmt(struct v4l2_subdev *sd,
struct v4l2_subdev_pad_config *cfg,
struct v4l2_subdev_format *format)
{
struct lt7911d_state *lt7911d = to_state(sd);
const struct lt7911d_mode *mode;

/* is overwritten by get_fmt */
u32 code = format->format.code;
int ret = lt7911d_get_fmt(sd, cfg, format);format->format.code = code;if (ret)return ret;switch (code) {
case MEDIA_BUS_FMT_UYVY8_2X8:break;default:return -EINVAL;
}if (format->which == V4L2_SUBDEV_FORMAT_TRY)return 0;lt7911d->mbus_fmt_code = format->format.code;
mode = lt7911d_find_best_fit(format);
lt7911d->cur_mode = mode;
enable_stream(sd, false);return 0;

}

static int lt7911d_g_frame_interval(struct v4l2_subdev *sd,
struct v4l2_subdev_frame_interval *fi)
{
struct lt7911d_state *lt7911d = to_state(sd);
const struct lt7911d_mode *mode = lt7911d->cur_mode;

mutex_lock(&lt7911d->confctl_mutex);
fi->interval = mode->max_fps;
mutex_unlock(&lt7911d->confctl_mutex);return 0;

}

static void lt7911d_get_module_inf(struct lt7911d_state *lt7911d,
struct rkmodule_inf *inf)
{
memset(inf, 0, sizeof(*inf));
strscpy(inf->base.sensor, LT7911D_NAME, sizeof(inf->base.sensor));
strscpy(inf->base.module, lt7911d->module_name, sizeof(inf->base.module));
strscpy(inf->base.lens, lt7911d->len_name, sizeof(inf->base.lens));
}

static long lt7911d_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
{
struct lt7911d_state *lt7911d = to_state(sd);
long ret = 0;

switch (cmd) {
case RKMODULE_GET_MODULE_INFO:lt7911d_get_module_inf(lt7911d, (struct rkmodule_inf *)arg);break;
case RKMODULE_GET_HDMI_MODE:*(int *)arg = RKMODULE_HDMIIN_MODE;break;
default:ret = -ENOIOCTLCMD;break;
}return ret;

}

#ifdef CONFIG_COMPAT
static long lt7911d_compat_ioctl32(struct v4l2_subdev *sd,
unsigned int cmd, unsigned long arg)
{
void __user *up = compat_ptr(arg);
struct rkmodule_inf *inf;
long ret;
int *seq;

switch (cmd) {
case RKMODULE_GET_MODULE_INFO:inf = kzalloc(sizeof(*inf), GFP_KERNEL);if (!inf) {ret = -ENOMEM;return ret;}ret = lt7911d_ioctl(sd, cmd, inf);if (!ret) {ret = copy_to_user(up, inf, sizeof(*inf));if (ret)ret = -EFAULT;}kfree(inf);break;
case RKMODULE_GET_HDMI_MODE:seq = kzalloc(sizeof(*seq), GFP_KERNEL);if (!seq) {ret = -ENOMEM;return ret;}ret = lt7911d_ioctl(sd, cmd, seq);if (!ret) {ret = copy_to_user(up, seq, sizeof(*seq));if (ret)ret = -EFAULT;}kfree(seq);break;
default:ret = -ENOIOCTLCMD;break;
}return ret;

}
#endif

static const struct v4l2_subdev_core_ops lt7911d_core_ops = {
.interrupt_service_routine = lt7911d_isr,
.subscribe_event = lt7911d_subscribe_event,
.unsubscribe_event = v4l2_event_subdev_unsubscribe,
.ioctl = lt7911d_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl32 = lt7911d_compat_ioctl32,
#endif
};

static const struct v4l2_subdev_video_ops lt7911d_video_ops = {
.g_input_status = lt7911d_g_input_status,
.s_dv_timings = lt7911d_s_dv_timings,
.g_dv_timings = lt7911d_g_dv_timings,
.query_dv_timings = lt7911d_query_dv_timings,
.s_stream = lt7911d_s_stream,
.g_frame_interval = lt7911d_g_frame_interval,
};

static const struct v4l2_subdev_pad_ops lt7911d_pad_ops = {
.enum_mbus_code = lt7911d_enum_mbus_code,
.enum_frame_size = lt7911d_enum_frame_sizes,
.enum_frame_interval = lt7911d_enum_frame_interval,
.set_fmt = lt7911d_set_fmt,
.get_fmt = lt7911d_get_fmt,
.enum_dv_timings = lt7911d_enum_dv_timings,
.dv_timings_cap = lt7911d_dv_timings_cap,
.get_mbus_config = lt7911d_g_mbus_config,
};

static const struct v4l2_subdev_ops lt7911d_ops = {
.core = &lt7911d_core_ops,
.video = &lt7911d_video_ops,
.pad = &lt7911d_pad_ops,
};

static const struct v4l2_ctrl_config lt7911d_ctrl_audio_sampling_rate = {
.id = RK_V4L2_CID_AUDIO_SAMPLING_RATE,
.name = “Audio sampling rate”,
.type = V4L2_CTRL_TYPE_INTEGER,
.min = 0,
.max = 768000,
.step = 1,
.def = 0,
.flags = V4L2_CTRL_FLAG_READ_ONLY,
};

static const struct v4l2_ctrl_config lt7911d_ctrl_audio_present = {
.id = RK_V4L2_CID_AUDIO_PRESENT,
.name = “Audio present”,
.type = V4L2_CTRL_TYPE_BOOLEAN,
.min = 0,
.max = 1,
.step = 1,
.def = 0,
.flags = V4L2_CTRL_FLAG_READ_ONLY,
};

static void lt7911d_reset(struct lt7911d_state lt7911d)
{
gpiod_set_value(lt7911d->reset_gpio, 0);
usleep_range(2000, 2100);
gpiod_set_value(lt7911d->reset_gpio, 1);
usleep_range(120
1000, 1211000);
gpiod_set_value(lt7911d->reset_gpio, 0);
usleep_range(300
1000, 310*1000);
}

static int lt7911d_init_v4l2_ctrls(struct lt7911d_state *lt7911d)
{
struct v4l2_subdev *sd;
int ret;

sd = &lt7911d->sd;
ret = v4l2_ctrl_handler_init(&lt7911d->hdl, 5);
if (ret)return ret;lt7911d->link_freq = v4l2_ctrl_new_int_menu(&lt7911d->hdl, NULL,V4L2_CID_LINK_FREQ,ARRAY_SIZE(link_freq_menu_items) - 1, 0,link_freq_menu_items);
lt7911d->pixel_rate = v4l2_ctrl_new_std(&lt7911d->hdl, NULL,V4L2_CID_PIXEL_RATE,0, LT7911D_PIXEL_RATE, 1, LT7911D_PIXEL_RATE);lt7911d->detect_tx_5v_ctrl = v4l2_ctrl_new_std(&lt7911d->hdl,NULL, V4L2_CID_DV_RX_POWER_PRESENT,0, 1, 0, 0);lt7911d->audio_sampling_rate_ctrl =v4l2_ctrl_new_custom(&lt7911d->hdl,&lt7911d_ctrl_audio_sampling_rate, NULL);
lt7911d->audio_present_ctrl = v4l2_ctrl_new_custom(&lt7911d->hdl,&lt7911d_ctrl_audio_present, NULL);sd->ctrl_handler = &lt7911d->hdl;
if (lt7911d->hdl.error) {ret = lt7911d->hdl.error;v4l2_err(sd, "cfg v4l2 ctrls failed! ret:%d\n", ret);return ret;
}__v4l2_ctrl_s_ctrl(lt7911d->link_freq, link_freq_menu_items[0]);
__v4l2_ctrl_s_ctrl_int64(lt7911d->pixel_rate, LT7911D_PIXEL_RATE);if (lt7911d_update_controls(sd)) {ret = -ENODEV;v4l2_err(sd, "update v4l2 ctrls failed! ret:%d\n", ret);return ret;
}return 0;

}

#ifdef CONFIG_OF
static int lt7911d_probe_of(struct lt7911d_state *lt7911d)
{
struct device *dev = &lt7911d->i2c_client->dev;
struct device_node *node = dev->of_node;
struct v4l2_fwnode_endpoint endpoint = { .bus_type = 0 };
struct device_node *ep;
int ret;

ret = of_property_read_u32(node, RKMODULE_CAMERA_MODULE_INDEX,&lt7911d->module_index);
ret |= of_property_read_string(node, RKMODULE_CAMERA_MODULE_FACING,&lt7911d->module_facing);
ret |= of_property_read_string(node, RKMODULE_CAMERA_MODULE_NAME,&lt7911d->module_name);
ret |= of_property_read_string(node, RKMODULE_CAMERA_LENS_NAME,&lt7911d->len_name);
if (ret) {dev_err(dev, "could not get module information!\n");return -EINVAL;
}lt7911d->power_gpio = devm_gpiod_get_optional(dev, "power",GPIOD_OUT_LOW);
if (IS_ERR(lt7911d->power_gpio)) {dev_err(dev, "failed to get power gpio\n");ret = PTR_ERR(lt7911d->power_gpio);return ret;
}lt7911d->reset_gpio = devm_gpiod_get_optional(dev, "reset",GPIOD_OUT_HIGH);
if (IS_ERR(lt7911d->reset_gpio)) {dev_err(dev, "failed to get reset gpio\n");ret = PTR_ERR(lt7911d->reset_gpio);return ret;
}lt7911d->plugin_det_gpio = devm_gpiod_get_optional(dev, "plugin-det",GPIOD_IN);
if (IS_ERR(lt7911d->plugin_det_gpio)) {dev_err(dev, "failed to get plugin det gpio\n");ret = PTR_ERR(lt7911d->plugin_det_gpio);return ret;
}ep = of_graph_get_next_endpoint(dev->of_node, NULL);
if (!ep) {dev_err(dev, "missing endpoint node\n");return -EINVAL;
}ret = v4l2_fwnode_endpoint_alloc_parse(of_fwnode_handle(ep), &endpoint);
if (ret) {dev_err(dev, "failed to parse endpoint\n");goto put_node;
}if (endpoint.bus_type != V4L2_MBUS_CSI2_DPHY ||endpoint.bus.mipi_csi2.num_data_lanes == 0) {dev_err(dev, "missing CSI-2 properties in endpoint\n");ret = -EINVAL;goto free_endpoint;
}lt7911d->xvclk = devm_clk_get(dev, "xvclk");
if (IS_ERR(lt7911d->xvclk)) {dev_err(dev, "failed to get xvclk\n");ret = -EINVAL;goto free_endpoint;
}ret = clk_prepare_enable(lt7911d->xvclk);
if (ret) {dev_err(dev, "Failed! to enable xvclk\n");goto free_endpoint;
}lt7911d->csi_lanes_in_use = endpoint.bus.mipi_csi2.num_data_lanes;
lt7911d->bus = endpoint.bus.mipi_csi2;
lt7911d->enable_hdcp = false;gpiod_set_value(lt7911d->power_gpio, 1);
lt7911d_reset(lt7911d);ret = 0;

free_endpoint:
v4l2_fwnode_endpoint_free(&endpoint);
put_node:
of_node_put(ep);
return ret;
}
#else
static inline int lt7911d_probe_of(struct lt7911d_state *state)
{
return -ENODEV;
}
#endif
static int lt7911d_check_chip_id(struct lt7911d_state *lt7911d)
{
struct device *dev = &lt7911d->i2c_client->dev;
struct v4l2_subdev *sd = &lt7911d->sd;
u8 id_h, id_l;
u32 chipid;
int ret = 0;

lt7911d_i2c_enable(sd);
id_l  = i2c_rd8(sd, CHIPID_REGL);
id_h  = i2c_rd8(sd, CHIPID_REGH);
lt7911d_i2c_disable(sd);chipid = (id_h << 8) | id_l;
if (chipid != LT7911D_CHIPID) {dev_err(dev, "chipid err, read:%#x, expect:%#x\n",chipid, LT7911D_CHIPID);return -EINVAL;
}
dev_info(dev, "check chipid ok, id:%#x", chipid);return ret;

}

static int lt7911d_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct lt7911d_state *lt7911d;
struct v4l2_subdev *sd;
struct device *dev = &client->dev;
char facing[2];
int err;

dev_info(dev, "driver version: %02x.%02x.%02x",DRIVER_VERSION >> 16,(DRIVER_VERSION & 0xff00) >> 8,DRIVER_VERSION & 0x00ff);lt7911d = devm_kzalloc(dev, sizeof(struct lt7911d_state), GFP_KERNEL);
if (!lt7911d)return -ENOMEM;sd = &lt7911d->sd;
lt7911d->i2c_client = client;
lt7911d->cur_mode = &supported_modes[0];
lt7911d->mbus_fmt_code = MEDIA_BUS_FMT_UYVY8_2X8;err = lt7911d_probe_of(lt7911d);
if (err) {v4l2_err(sd, "lt7911d_parse_of failed! err:%d\n", err);return err;
}err = lt7911d_check_chip_id(lt7911d);
if (err < 0)return err;lt7911d_reset(lt7911d);mutex_init(&lt7911d->confctl_mutex);
err = lt7911d_init_v4l2_ctrls(lt7911d);
if (err)goto err_free_hdl;client->flags |= I2C_CLIENT_SCCB;

#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
v4l2_i2c_subdev_init(sd, client, &lt7911d_ops);
sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS;
#endif

#if defined(CONFIG_MEDIA_CONTROLLER)
lt7911d->pad.flags = MEDIA_PAD_FL_SOURCE;
sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
err = media_entity_pads_init(&sd->entity, 1, &lt7911d->pad);
if (err < 0) {
v4l2_err(sd, “media entity init failed! err:%d\n”, err);
goto err_free_hdl;
}
#endif
memset(facing, 0, sizeof(facing));
if (strcmp(lt7911d->module_facing, “back”) == 0)
facing[0] = ‘b’;
else
facing[0] = ‘f’;

snprintf(sd->name, sizeof(sd->name), "m%02d_%s_%s %s",lt7911d->module_index, facing,LT7911D_NAME, dev_name(sd->dev));
err = v4l2_async_register_subdev_sensor_common(sd);
if (err < 0) {v4l2_err(sd, "v4l2 register subdev failed! err:%d\n", err);goto err_clean_entity;
}INIT_DELAYED_WORK(&lt7911d->delayed_work_enable_hotplug,lt7911d_delayed_work_enable_hotplug);
INIT_DELAYED_WORK(&lt7911d->delayed_work_res_change,lt7911d_delayed_work_res_change);if (lt7911d->i2c_client->irq) {v4l2_dbg(1, debug, sd, "cfg lt7911d irq!\n");err = devm_request_threaded_irq(dev,lt7911d->i2c_client->irq,NULL, lt7911d_res_change_irq_handler,IRQF_TRIGGER_RISING | IRQF_ONESHOT,"lt7911d", lt7911d);if (err) {v4l2_err(sd, "request irq failed! err:%d\n", err);goto err_work_queues;}
} else {v4l2_dbg(1, debug, sd, "no irq, cfg poll!\n");INIT_WORK(&lt7911d->work_i2c_poll, lt7911d_work_i2c_poll);timer_setup(&lt7911d->timer, lt7911d_irq_poll_timer, 0);lt7911d->timer.expires = jiffies +msecs_to_jiffies(POLL_INTERVAL_MS);add_timer(&lt7911d->timer);
}lt7911d->plugin_irq = gpiod_to_irq(lt7911d->plugin_det_gpio);
if (lt7911d->plugin_irq < 0)dev_err(dev, "failed to get plugin det irq, maybe no use\n");err = devm_request_threaded_irq(dev, lt7911d->plugin_irq, NULL,plugin_detect_irq_handler, IRQF_TRIGGER_FALLING |IRQF_TRIGGER_RISING | IRQF_ONESHOT, "lt7911d",lt7911d);
if (err)dev_err(dev, "failed to register plugin det irq (%d), maybe no use\n", err);err = v4l2_ctrl_handler_setup(sd->ctrl_handler);
if (err) {v4l2_err(sd, "v4l2 ctrl handler setup failed! err:%d\n", err);goto err_work_queues;
}v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name,client->addr << 1, client->adapter->name);return 0;

err_work_queues:
if (!lt7911d->i2c_client->irq)
flush_work(&lt7911d->work_i2c_poll);
cancel_delayed_work(&lt7911d->delayed_work_enable_hotplug);
cancel_delayed_work(&lt7911d->delayed_work_res_change);
err_clean_entity:
#if defined(CONFIG_MEDIA_CONTROLLER)
media_entity_cleanup(&sd->entity);
#endif
err_free_hdl:
v4l2_ctrl_handler_free(&lt7911d->hdl);
mutex_destroy(&lt7911d->confctl_mutex);
return err;
}

static int lt7911d_remove(struct i2c_client *client)
{
struct v4l2_subdev *sd = i2c_get_clientdata(client);
struct lt7911d_state *lt7911d = to_state(sd);

if (!lt7911d->i2c_client->irq) {del_timer_sync(&lt7911d->timer);flush_work(&lt7911d->work_i2c_poll);
}
cancel_delayed_work_sync(&lt7911d->delayed_work_enable_hotplug);
cancel_delayed_work_sync(&lt7911d->delayed_work_res_change);
v4l2_async_unregister_subdev(sd);
v4l2_device_unregister_subdev(sd);

#if defined(CONFIG_MEDIA_CONTROLLER)
media_entity_cleanup(&sd->entity);
#endif
v4l2_ctrl_handler_free(&lt7911d->hdl);
mutex_destroy(&lt7911d->confctl_mutex);
clk_disable_unprepare(lt7911d->xvclk);

return 0;

}

#if IS_ENABLED(CONFIG_OF)
static const struct of_device_id lt7911d_of_match[] = {
{ .compatible = “lontium,lt7911d” },
{},
};
MODULE_DEVICE_TABLE(of, lt7911d_of_match);
#endif

static struct i2c_driver lt7911d_driver = {
.driver = {
.name = LT7911D_NAME,
.of_match_table = of_match_ptr(lt7911d_of_match),
},
.probe = lt7911d_probe,
.remove = lt7911d_remove,
};

static int __init lt7911d_driver_init(void)
{
return i2c_add_driver(&lt7911d_driver);
}

static void __exit lt7911d_driver_exit(void)
{
i2c_del_driver(&lt7911d_driver);
}

device_initcall_sync(lt7911d_driver_init);
module_exit(lt7911d_driver_exit);

MODULE_DESCRIPTION(“Lontium lt7911d HDMI to CSI-2 bridge driver”);
MODULE_AUTHOR(“xxx”);
MODULE_LICENSE(“GPL v2”);

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/464543.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

我谈正态分布——正态偏态

目录 pdf和cdf参数 标准正态分布期望和方差分布形态 3 σ 3\sigma 3σ原则 正态和偏态正态偏态瑞利分布偏度 (Skewness)峰度 (Kurtosis) 比较 正态分布的英文是Normal Distribution&#xff0c;normal是“正常”或“标准”的意思&#xff0c;中文翻译是正态&#xff0c;多完美的…

杨传辉:云+AI 时代的一体化数据库|OceanBase发布会实录

在 2024 OceanBase 年度发布会 上&#xff0c; OceanBase CTO 杨传辉进行了主题为《云和 AI 时代的一体化数据库战略思考》的演讲&#xff0c;本文为演讲实录&#xff0c;欢迎阅读。 视频观看可点击&#xff1a;https://www.oceanbase.com/video/9001825 各位 OceanBase 的客…

华为OD机试 - 无重复字符的元素长度乘积的最大值(Python/JS/C/C++ 2024 C卷 100分)

华为OD机试 2024E卷题库疯狂收录中&#xff0c;刷题点这里 专栏导读 本专栏收录于《华为OD机试真题&#xff08;Python/JS/C/C&#xff09;》。 刷的越多&#xff0c;抽中的概率越大&#xff0c;私信哪吒&#xff0c;备注华为OD&#xff0c;加入华为OD刷题交流群&#xff0c;…

【格式化查看JSON文件】coco的json文件内容都在一行如何按照json格式查看

文章目录 1.使用 Python 中的 json 库2. 使用浏览器3. notepad4. VSCode 如果COCO的JSON文件内容在一行显示&#xff0c;这通常意味着文件被压缩或者是在传输过程中出现了问题。 1.使用 Python 中的 json 库 想更好地查看 COCO 格式的 JSON 标签&#xff0c;可以将其格式化为更…

2025生物发酵展(济南)为生物制造产业注入新活力共谱行业新篇章

2025第十四届国际生物发酵展将于3月3-5日济南盛大举办&#xff01;产业链逐步完整&#xff0c;展会面积再创历史新高&#xff0c;展览面积较上届增涨至60000平方米&#xff0c;专业观众40000&#xff0c;品牌展商800&#xff0c;同期活动会议增加至50场&#xff0c;展会同期将举…

kafka里的consumer 是推还是拉?

大家好&#xff0c;我是锋哥。今天分享关于【kafka里的consumer 是推还是拉&#xff1f;】面试题&#xff1f;希望对大家有帮助&#xff1b; kafka里的consumer 是推还是拉&#xff1f; 1000道 互联网大厂Java工程师 精选面试题-Java资源分享网 在Kafka中&#xff0c;消费者&…

Visual Studio | 配置管理

文章目录 一、配置管理1、项目属性1.1、常规1.2、VC 目录1.3、C/C -> 常规1.4、C/C -> 预处理器1.5、C/C -> 预编译头1.6、连接器 -> 常规1.7、连接器 -> 输入 2、编辑2.1、显示空格或tab符 一、配置管理 1、项目属性 1.1、常规 字段功能目标平台版本用于生成…

Docker打包自己项目推到Docker hub仓库(windows10)

一、启用Hyper-V和容器特性 1.应用和功能 2.点击程序和功能 3.启用或关闭Windows功能 4.开启Hyper-V 和 容器特性 记得重启生效&#xff01;&#xff01;&#xff01; 二、安装WSL2&#xff1a;写文章-CSDN创作中心https://mp.csdn.net/mp_blog/creation/editor/143057041 三…

js.轮转数组和旋转链表

这是两个相似的题型&#xff0c;一个是数组&#xff0c;另一个是链表。 链接&#xff1a;189. 轮转数组 - 力扣&#xff08;LeetCode&#xff09; 题目&#xff1a; 给定一个整数数组 nums&#xff0c;将数组中的元素向右轮转 k 个位置&#xff0c;其中 k 是非负数。 示例 1:…

mysql left join group_concat 主表丢失数据

问题出现的场景&#xff1a; 有一个主表 a&#xff0c;一个子表 b a表有两条数据&#xff0c;a表第一条数据在b表中有一条子数据&#xff0c;a表第二条数据在b表中有两条子数据。 现在想要查询出来a表的所有数据和a表的子表b的id&#xff0c;b的id 使用GROUP_CONCAT拼接 有…

Spring 中循环依赖 三级缓存

在Spring框架中&#xff0c;循环依赖是一个常见的问题&#xff0c;它指的是两个或多个Bean之间互相依赖&#xff0c;形成一个闭环&#xff0c;导致无法准确地完成对象的创建和初始化。为了解决这个问题&#xff0c;Spring引入了三级缓存机制。以下是对Spring中循环依赖和三级缓…

新能源汽车与公共充电桩布局

近年来,全球范围内对新能源汽车产业的推动力度不断增强,中国新能源汽车市场也呈现蓬勃发展的势头,在政策与市场的共同推动下,新能源汽车销量持续增长。然而,据中国充电联盟数据显示,充电基础设施建设滞后于新能源汽车数量增长的现状导致充电桩供需不平衡,公共充电桩服务空白区域…

【深度学习基础】常用图像卷积核类型

&#x1f308; 个人主页&#xff1a;十二月的猫-CSDN博客 &#x1f525; 系列专栏&#xff1a; &#x1f3c0;深度学习_十二月的猫的博客-CSDN博客 &#x1f4aa;&#x1f3fb; 十二月的寒冬阻挡不了春天的脚步&#xff0c;十二点的黑夜遮蔽不住黎明的曙光 目录 1. 前言 2. 常…

一二三应用开发平台自定义查询设计与实现系列3——通用化重构

通用化重构 前面我们以一个实体为目标对象&#xff0c;完成了功能开发与调试。 在此基础上&#xff0c;我们对功能进行重构&#xff0c;使其成为平台的标准化、通用化的功能。 前端重构 首先&#xff0c;先把自定义组件挪到了平台公共组件目录下&#xff0c;如下&#xff1…

RabbitMQ交换机类型

RabbitMQ交换机类型 1、RabbitMQ工作模型2、RabbitMQ交换机类型2.1、Fanout Exchange&#xff08;扇形&#xff09;2.1.1、介绍2.1.2、示例2.1.2.1、生产者2.1.2.2、消费者2.1.2.3、测试 2.2、Direct Exchange&#xff08;直连&#xff09;2.2.1、介绍2.2.2、示例2.2.2.1、生产…

qt QMenuBar详解

1、概述 QMenuBar是Qt框架中用于创建菜单栏的类&#xff0c;它继承自QWidget。QMenuBar通常位于QMainWindow对象的标题栏下方&#xff0c;用于组织和管理多个QMenu&#xff08;菜单&#xff09;和QAction&#xff08;动作&#xff09;。菜单栏提供了一个水平排列的容器&#x…

数据转换 | Matlab基于SP符号递归图(Symbolic recurrence plots)一维数据转二维图像方法

目录 基本介绍程序设计参考资料获取方式 基本介绍 Matlab基于SP符号递归图&#xff08;Symbolic recurrence plots&#xff09;一维数据转二维图像方法 符号递归图(Symbolic recurrence plots)是一种一维时间序列转图像的技术&#xff0c;可用于平稳和非平稳数据集;对噪声具有…

特殊矩阵的压缩存储

一维数组的存储结构 ElemType arr[10]; 各数组元素大小相同&#xff0c;且物理上连续存放。 数组元素a[i]的存放地址 LOC i * sizeof(ElemType)。&#xff08;LOC为起始地址&#xff09; 二维数组的存储结构 ElemType b[2][4];二维数组也具有随机存取的特性&#xff08;需…

MySQL utf8mb3 和 utf8mb4引发的问题

问题描述 Cause: java.sql.SQLException: Incorrect string value: \xF4\x8F\xBB\xBF-b... for column sddd_aaa_ark at row 1 sddd_aaa_ark 存储中文字符时&#xff0c;出现上述问题 原因分析 sddd_aaa_ark在数据库中结构是 utf8字符的最大字节数是3 byte&#xff0c;但是某些…

RK3568开发板Openwrt文件系统构建

RK3568开发板Openwrt文件系统构建 iTOP-RK3568开发板使用教程更新&#xff0c;后续资料会不断更新&#xff0c;不断完善&#xff0c;帮助用户快速入门&#xff0c;大大提升研发速度。 本次更新内容为《iTOP-3568开发板文件系统构建手册》&#xff0c;对Openwrt文件系统的编译…