mt9m111 285 drivers/media/i2c/mt9m111.c static const struct mt9m111_datafmt *mt9m111_find_datafmt(struct mt9m111 *mt9m111, mt9m111 293 drivers/media/i2c/mt9m111.c return mt9m111->fmt; mt9m111 296 drivers/media/i2c/mt9m111.c static struct mt9m111 *to_mt9m111(const struct i2c_client *client) mt9m111 298 drivers/media/i2c/mt9m111.c return container_of(i2c_get_clientdata(client), struct mt9m111, subdev); mt9m111 305 drivers/media/i2c/mt9m111.c struct mt9m111 *mt9m111 = to_mt9m111(client); mt9m111 308 drivers/media/i2c/mt9m111.c if (page == mt9m111->lastpage) mt9m111 315 drivers/media/i2c/mt9m111.c mt9m111->lastpage = page; mt9m111 376 drivers/media/i2c/mt9m111.c static int mt9m111_set_context(struct mt9m111 *mt9m111, mt9m111 379 drivers/media/i2c/mt9m111.c struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); mt9m111 383 drivers/media/i2c/mt9m111.c static int mt9m111_setup_rect_ctx(struct mt9m111 *mt9m111, mt9m111 387 drivers/media/i2c/mt9m111.c struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); mt9m111 398 drivers/media/i2c/mt9m111.c static int mt9m111_setup_geometry(struct mt9m111 *mt9m111, struct v4l2_rect *rect, mt9m111 401 drivers/media/i2c/mt9m111.c struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); mt9m111 416 drivers/media/i2c/mt9m111.c ret = mt9m111_setup_rect_ctx(mt9m111, &context_b, mt9m111 419 drivers/media/i2c/mt9m111.c ret = mt9m111_setup_rect_ctx(mt9m111, &context_a, mt9m111 430 drivers/media/i2c/mt9m111.c static int mt9m111_enable(struct mt9m111 *mt9m111) mt9m111 432 drivers/media/i2c/mt9m111.c struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); mt9m111 436 drivers/media/i2c/mt9m111.c static int mt9m111_reset(struct mt9m111 *mt9m111) mt9m111 438 drivers/media/i2c/mt9m111.c struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); mt9m111 456 drivers/media/i2c/mt9m111.c struct mt9m111 *mt9m111 = to_mt9m111(client); mt9m111 465 drivers/media/i2c/mt9m111.c if (mt9m111->fmt->code == MEDIA_BUS_FMT_SBGGR8_1X8 || mt9m111 466 drivers/media/i2c/mt9m111.c mt9m111->fmt->code == MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE) { mt9m111 482 drivers/media/i2c/mt9m111.c width = min(mt9m111->width, rect.width); mt9m111 483 drivers/media/i2c/mt9m111.c height = min(mt9m111->height, rect.height); mt9m111 485 drivers/media/i2c/mt9m111.c ret = mt9m111_setup_geometry(mt9m111, &rect, width, height, mt9m111->fmt->code); mt9m111 487 drivers/media/i2c/mt9m111.c mt9m111->rect = rect; mt9m111 488 drivers/media/i2c/mt9m111.c mt9m111->width = width; mt9m111 489 drivers/media/i2c/mt9m111.c mt9m111->height = height; mt9m111 500 drivers/media/i2c/mt9m111.c struct mt9m111 *mt9m111 = to_mt9m111(client); mt9m111 513 drivers/media/i2c/mt9m111.c sel->r = mt9m111->rect; mt9m111 525 drivers/media/i2c/mt9m111.c struct mt9m111 *mt9m111 = container_of(sd, struct mt9m111, subdev); mt9m111 540 drivers/media/i2c/mt9m111.c mf->width = mt9m111->width; mt9m111 541 drivers/media/i2c/mt9m111.c mf->height = mt9m111->height; mt9m111 542 drivers/media/i2c/mt9m111.c mf->code = mt9m111->fmt->code; mt9m111 543 drivers/media/i2c/mt9m111.c mf->colorspace = mt9m111->fmt->colorspace; mt9m111 552 drivers/media/i2c/mt9m111.c static int mt9m111_set_pixfmt(struct mt9m111 *mt9m111, mt9m111 555 drivers/media/i2c/mt9m111.c struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); mt9m111 614 drivers/media/i2c/mt9m111.c if (mt9m111->pclk_sample == 0) mt9m111 632 drivers/media/i2c/mt9m111.c struct mt9m111 *mt9m111 = container_of(sd, struct mt9m111, subdev); mt9m111 634 drivers/media/i2c/mt9m111.c struct v4l2_rect *rect = &mt9m111->rect; mt9m111 638 drivers/media/i2c/mt9m111.c if (mt9m111->is_streaming) mt9m111 644 drivers/media/i2c/mt9m111.c fmt = mt9m111_find_datafmt(mt9m111, mf->code); mt9m111 685 drivers/media/i2c/mt9m111.c ret = mt9m111_setup_geometry(mt9m111, rect, mf->width, mf->height, mf->code); mt9m111 687 drivers/media/i2c/mt9m111.c ret = mt9m111_set_pixfmt(mt9m111, mf->code); mt9m111 689 drivers/media/i2c/mt9m111.c mt9m111->width = mf->width; mt9m111 690 drivers/media/i2c/mt9m111.c mt9m111->height = mf->height; mt9m111 691 drivers/media/i2c/mt9m111.c mt9m111->fmt = fmt; mt9m111 698 drivers/media/i2c/mt9m111.c mt9m111_find_mode(struct mt9m111 *mt9m111, unsigned int req_fps, mt9m111 702 drivers/media/i2c/mt9m111.c struct v4l2_rect *sensor_rect = &mt9m111->rect; mt9m111 714 drivers/media/i2c/mt9m111.c dev_info(mt9m111->subdev.dev, mt9m111 722 drivers/media/i2c/mt9m111.c dev_dbg(mt9m111->subdev.dev, mt9m111 747 drivers/media/i2c/mt9m111.c mt9m111->ctx = (best_gap_idx == MT9M111_MODE_QSXGA_30FPS) ? &context_a : mt9m111 787 drivers/media/i2c/mt9m111.c static int mt9m111_set_flip(struct mt9m111 *mt9m111, int flip, int mask) mt9m111 789 drivers/media/i2c/mt9m111.c struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); mt9m111 793 drivers/media/i2c/mt9m111.c ret = mt9m111_reg_set(client, mt9m111->ctx->read_mode, mask); mt9m111 795 drivers/media/i2c/mt9m111.c ret = mt9m111_reg_clear(client, mt9m111->ctx->read_mode, mask); mt9m111 800 drivers/media/i2c/mt9m111.c static int mt9m111_get_global_gain(struct mt9m111 *mt9m111) mt9m111 802 drivers/media/i2c/mt9m111.c struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); mt9m111 812 drivers/media/i2c/mt9m111.c static int mt9m111_set_global_gain(struct mt9m111 *mt9m111, int gain) mt9m111 814 drivers/media/i2c/mt9m111.c struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); mt9m111 830 drivers/media/i2c/mt9m111.c static int mt9m111_set_autoexposure(struct mt9m111 *mt9m111, int val) mt9m111 832 drivers/media/i2c/mt9m111.c struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); mt9m111 839 drivers/media/i2c/mt9m111.c static int mt9m111_set_autowhitebalance(struct mt9m111 *mt9m111, int on) mt9m111 841 drivers/media/i2c/mt9m111.c struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); mt9m111 859 drivers/media/i2c/mt9m111.c static int mt9m111_set_test_pattern(struct mt9m111 *mt9m111, int val) mt9m111 861 drivers/media/i2c/mt9m111.c struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); mt9m111 867 drivers/media/i2c/mt9m111.c static int mt9m111_set_colorfx(struct mt9m111 *mt9m111, int val) mt9m111 869 drivers/media/i2c/mt9m111.c struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); mt9m111 892 drivers/media/i2c/mt9m111.c struct mt9m111 *mt9m111 = container_of(ctrl->handler, mt9m111 893 drivers/media/i2c/mt9m111.c struct mt9m111, hdl); mt9m111 897 drivers/media/i2c/mt9m111.c return mt9m111_set_flip(mt9m111, ctrl->val, mt9m111 900 drivers/media/i2c/mt9m111.c return mt9m111_set_flip(mt9m111, ctrl->val, mt9m111 903 drivers/media/i2c/mt9m111.c return mt9m111_set_global_gain(mt9m111, ctrl->val); mt9m111 905 drivers/media/i2c/mt9m111.c return mt9m111_set_autoexposure(mt9m111, ctrl->val); mt9m111 907 drivers/media/i2c/mt9m111.c return mt9m111_set_autowhitebalance(mt9m111, ctrl->val); mt9m111 909 drivers/media/i2c/mt9m111.c return mt9m111_set_test_pattern(mt9m111, ctrl->val); mt9m111 911 drivers/media/i2c/mt9m111.c return mt9m111_set_colorfx(mt9m111, ctrl->val); mt9m111 917 drivers/media/i2c/mt9m111.c static int mt9m111_suspend(struct mt9m111 *mt9m111) mt9m111 919 drivers/media/i2c/mt9m111.c struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); mt9m111 922 drivers/media/i2c/mt9m111.c v4l2_ctrl_s_ctrl(mt9m111->gain, mt9m111_get_global_gain(mt9m111)); mt9m111 935 drivers/media/i2c/mt9m111.c static void mt9m111_restore_state(struct mt9m111 *mt9m111) mt9m111 937 drivers/media/i2c/mt9m111.c struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); mt9m111 939 drivers/media/i2c/mt9m111.c mt9m111_set_context(mt9m111, mt9m111->ctx); mt9m111 940 drivers/media/i2c/mt9m111.c mt9m111_set_pixfmt(mt9m111, mt9m111->fmt->code); mt9m111 941 drivers/media/i2c/mt9m111.c mt9m111_setup_geometry(mt9m111, &mt9m111->rect, mt9m111 942 drivers/media/i2c/mt9m111.c mt9m111->width, mt9m111->height, mt9m111->fmt->code); mt9m111 943 drivers/media/i2c/mt9m111.c v4l2_ctrl_handler_setup(&mt9m111->hdl); mt9m111 944 drivers/media/i2c/mt9m111.c mt9m111_reg_mask(client, mt9m111->ctx->read_mode, mt9m111 945 drivers/media/i2c/mt9m111.c mt9m111->current_mode->reg_val, mt9m111 946 drivers/media/i2c/mt9m111.c mt9m111->current_mode->reg_mask); mt9m111 949 drivers/media/i2c/mt9m111.c static int mt9m111_resume(struct mt9m111 *mt9m111) mt9m111 951 drivers/media/i2c/mt9m111.c int ret = mt9m111_enable(mt9m111); mt9m111 953 drivers/media/i2c/mt9m111.c ret = mt9m111_reset(mt9m111); mt9m111 955 drivers/media/i2c/mt9m111.c mt9m111_restore_state(mt9m111); mt9m111 960 drivers/media/i2c/mt9m111.c static int mt9m111_init(struct mt9m111 *mt9m111) mt9m111 962 drivers/media/i2c/mt9m111.c struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); mt9m111 965 drivers/media/i2c/mt9m111.c ret = mt9m111_enable(mt9m111); mt9m111 967 drivers/media/i2c/mt9m111.c ret = mt9m111_reset(mt9m111); mt9m111 969 drivers/media/i2c/mt9m111.c ret = mt9m111_set_context(mt9m111, mt9m111->ctx); mt9m111 975 drivers/media/i2c/mt9m111.c static int mt9m111_power_on(struct mt9m111 *mt9m111) mt9m111 977 drivers/media/i2c/mt9m111.c struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); mt9m111 980 drivers/media/i2c/mt9m111.c ret = v4l2_clk_enable(mt9m111->clk); mt9m111 984 drivers/media/i2c/mt9m111.c ret = regulator_enable(mt9m111->regulator); mt9m111 988 drivers/media/i2c/mt9m111.c ret = mt9m111_resume(mt9m111); mt9m111 995 drivers/media/i2c/mt9m111.c regulator_disable(mt9m111->regulator); mt9m111 998 drivers/media/i2c/mt9m111.c v4l2_clk_disable(mt9m111->clk); mt9m111 1005 drivers/media/i2c/mt9m111.c static void mt9m111_power_off(struct mt9m111 *mt9m111) mt9m111 1007 drivers/media/i2c/mt9m111.c mt9m111_suspend(mt9m111); mt9m111 1008 drivers/media/i2c/mt9m111.c regulator_disable(mt9m111->regulator); mt9m111 1009 drivers/media/i2c/mt9m111.c v4l2_clk_disable(mt9m111->clk); mt9m111 1014 drivers/media/i2c/mt9m111.c struct mt9m111 *mt9m111 = container_of(sd, struct mt9m111, subdev); mt9m111 1017 drivers/media/i2c/mt9m111.c mutex_lock(&mt9m111->power_lock); mt9m111 1023 drivers/media/i2c/mt9m111.c if (mt9m111->power_count == !on) { mt9m111 1025 drivers/media/i2c/mt9m111.c ret = mt9m111_power_on(mt9m111); mt9m111 1027 drivers/media/i2c/mt9m111.c mt9m111_power_off(mt9m111); mt9m111 1032 drivers/media/i2c/mt9m111.c mt9m111->power_count += on ? 1 : -1; mt9m111 1033 drivers/media/i2c/mt9m111.c WARN_ON(mt9m111->power_count < 0); mt9m111 1036 drivers/media/i2c/mt9m111.c mutex_unlock(&mt9m111->power_lock); mt9m111 1058 drivers/media/i2c/mt9m111.c struct mt9m111 *mt9m111 = container_of(sd, struct mt9m111, subdev); mt9m111 1060 drivers/media/i2c/mt9m111.c fi->interval = mt9m111->frame_interval; mt9m111 1068 drivers/media/i2c/mt9m111.c struct mt9m111 *mt9m111 = container_of(sd, struct mt9m111, subdev); mt9m111 1073 drivers/media/i2c/mt9m111.c if (mt9m111->is_streaming) mt9m111 1087 drivers/media/i2c/mt9m111.c mode = mt9m111_find_mode(mt9m111, fps, mt9m111->width, mt9m111->height); mt9m111 1096 drivers/media/i2c/mt9m111.c mt9m111->current_mode = mode; mt9m111 1097 drivers/media/i2c/mt9m111.c mt9m111->frame_interval = fi->interval; mt9m111 1115 drivers/media/i2c/mt9m111.c struct mt9m111 *mt9m111 = container_of(sd, struct mt9m111, subdev); mt9m111 1117 drivers/media/i2c/mt9m111.c mt9m111->is_streaming = !!enable; mt9m111 1143 drivers/media/i2c/mt9m111.c struct mt9m111 *mt9m111 = container_of(sd, struct mt9m111, subdev); mt9m111 1149 drivers/media/i2c/mt9m111.c cfg->flags |= mt9m111->pclk_sample ? V4L2_MBUS_PCLK_SAMPLE_RISING : mt9m111 1185 drivers/media/i2c/mt9m111.c struct mt9m111 *mt9m111 = to_mt9m111(client); mt9m111 1189 drivers/media/i2c/mt9m111.c ret = mt9m111_s_power(&mt9m111->subdev, 1); mt9m111 1211 drivers/media/i2c/mt9m111.c ret = mt9m111_init(mt9m111); mt9m111 1215 drivers/media/i2c/mt9m111.c ret = v4l2_ctrl_handler_setup(&mt9m111->hdl); mt9m111 1218 drivers/media/i2c/mt9m111.c mt9m111_s_power(&mt9m111->subdev, 0); mt9m111 1222 drivers/media/i2c/mt9m111.c static int mt9m111_probe_fw(struct i2c_client *client, struct mt9m111 *mt9m111) mt9m111 1238 drivers/media/i2c/mt9m111.c mt9m111->pclk_sample = !!(bus_cfg.bus.parallel.flags & mt9m111 1248 drivers/media/i2c/mt9m111.c struct mt9m111 *mt9m111; mt9m111 1258 drivers/media/i2c/mt9m111.c mt9m111 = devm_kzalloc(&client->dev, sizeof(struct mt9m111), GFP_KERNEL); mt9m111 1259 drivers/media/i2c/mt9m111.c if (!mt9m111) mt9m111 1263 drivers/media/i2c/mt9m111.c ret = mt9m111_probe_fw(client, mt9m111); mt9m111 1268 drivers/media/i2c/mt9m111.c mt9m111->clk = v4l2_clk_get(&client->dev, "mclk"); mt9m111 1269 drivers/media/i2c/mt9m111.c if (IS_ERR(mt9m111->clk)) mt9m111 1270 drivers/media/i2c/mt9m111.c return PTR_ERR(mt9m111->clk); mt9m111 1272 drivers/media/i2c/mt9m111.c mt9m111->regulator = devm_regulator_get(&client->dev, "vdd"); mt9m111 1273 drivers/media/i2c/mt9m111.c if (IS_ERR(mt9m111->regulator)) { mt9m111 1275 drivers/media/i2c/mt9m111.c PTR_ERR(mt9m111->regulator)); mt9m111 1276 drivers/media/i2c/mt9m111.c return PTR_ERR(mt9m111->regulator); mt9m111 1280 drivers/media/i2c/mt9m111.c mt9m111->ctx = &context_b; mt9m111 1282 drivers/media/i2c/mt9m111.c v4l2_i2c_subdev_init(&mt9m111->subdev, client, &mt9m111_subdev_ops); mt9m111 1283 drivers/media/i2c/mt9m111.c mt9m111->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | mt9m111 1286 drivers/media/i2c/mt9m111.c v4l2_ctrl_handler_init(&mt9m111->hdl, 7); mt9m111 1287 drivers/media/i2c/mt9m111.c v4l2_ctrl_new_std(&mt9m111->hdl, &mt9m111_ctrl_ops, mt9m111 1289 drivers/media/i2c/mt9m111.c v4l2_ctrl_new_std(&mt9m111->hdl, &mt9m111_ctrl_ops, mt9m111 1291 drivers/media/i2c/mt9m111.c v4l2_ctrl_new_std(&mt9m111->hdl, &mt9m111_ctrl_ops, mt9m111 1293 drivers/media/i2c/mt9m111.c mt9m111->gain = v4l2_ctrl_new_std(&mt9m111->hdl, &mt9m111_ctrl_ops, mt9m111 1295 drivers/media/i2c/mt9m111.c v4l2_ctrl_new_std_menu(&mt9m111->hdl, mt9m111 1298 drivers/media/i2c/mt9m111.c v4l2_ctrl_new_std_menu_items(&mt9m111->hdl, mt9m111 1302 drivers/media/i2c/mt9m111.c v4l2_ctrl_new_std_menu(&mt9m111->hdl, &mt9m111_ctrl_ops, mt9m111 1310 drivers/media/i2c/mt9m111.c mt9m111->subdev.ctrl_handler = &mt9m111->hdl; mt9m111 1311 drivers/media/i2c/mt9m111.c if (mt9m111->hdl.error) { mt9m111 1312 drivers/media/i2c/mt9m111.c ret = mt9m111->hdl.error; mt9m111 1317 drivers/media/i2c/mt9m111.c mt9m111->pad.flags = MEDIA_PAD_FL_SOURCE; mt9m111 1318 drivers/media/i2c/mt9m111.c mt9m111->subdev.entity.function = MEDIA_ENT_F_CAM_SENSOR; mt9m111 1319 drivers/media/i2c/mt9m111.c ret = media_entity_pads_init(&mt9m111->subdev.entity, 1, &mt9m111->pad); mt9m111 1324 drivers/media/i2c/mt9m111.c mt9m111->current_mode = &mt9m111_mode_data[MT9M111_MODE_SXGA_15FPS]; mt9m111 1325 drivers/media/i2c/mt9m111.c mt9m111->frame_interval.numerator = 1; mt9m111 1326 drivers/media/i2c/mt9m111.c mt9m111->frame_interval.denominator = mt9m111->current_mode->max_fps; mt9m111 1329 drivers/media/i2c/mt9m111.c mt9m111->rect.left = MT9M111_MIN_DARK_COLS; mt9m111 1330 drivers/media/i2c/mt9m111.c mt9m111->rect.top = MT9M111_MIN_DARK_ROWS; mt9m111 1331 drivers/media/i2c/mt9m111.c mt9m111->rect.width = MT9M111_MAX_WIDTH; mt9m111 1332 drivers/media/i2c/mt9m111.c mt9m111->rect.height = MT9M111_MAX_HEIGHT; mt9m111 1333 drivers/media/i2c/mt9m111.c mt9m111->width = mt9m111->rect.width; mt9m111 1334 drivers/media/i2c/mt9m111.c mt9m111->height = mt9m111->rect.height; mt9m111 1335 drivers/media/i2c/mt9m111.c mt9m111->fmt = &mt9m111_colour_fmts[0]; mt9m111 1336 drivers/media/i2c/mt9m111.c mt9m111->lastpage = -1; mt9m111 1337 drivers/media/i2c/mt9m111.c mutex_init(&mt9m111->power_lock); mt9m111 1343 drivers/media/i2c/mt9m111.c mt9m111->subdev.dev = &client->dev; mt9m111 1344 drivers/media/i2c/mt9m111.c ret = v4l2_async_register_subdev(&mt9m111->subdev); mt9m111 1352 drivers/media/i2c/mt9m111.c media_entity_cleanup(&mt9m111->subdev.entity); mt9m111 1355 drivers/media/i2c/mt9m111.c v4l2_ctrl_handler_free(&mt9m111->hdl); mt9m111 1357 drivers/media/i2c/mt9m111.c v4l2_clk_put(mt9m111->clk); mt9m111 1364 drivers/media/i2c/mt9m111.c struct mt9m111 *mt9m111 = to_mt9m111(client); mt9m111 1366 drivers/media/i2c/mt9m111.c v4l2_async_unregister_subdev(&mt9m111->subdev); mt9m111 1367 drivers/media/i2c/mt9m111.c media_entity_cleanup(&mt9m111->subdev.entity); mt9m111 1368 drivers/media/i2c/mt9m111.c v4l2_clk_put(mt9m111->clk); mt9m111 1369 drivers/media/i2c/mt9m111.c v4l2_ctrl_handler_free(&mt9m111->hdl); mt9m111 225 drivers/media/usb/gspca/m5602/m5602_core.c sd->sensor = &mt9m111; mt9m111 203 drivers/media/usb/gspca/m5602/m5602_mt9m111.c pr_info("Forcing a %s sensor\n", mt9m111.name); mt9m111 113 drivers/media/usb/gspca/m5602/m5602_mt9m111.h static const struct m5602_sensor mt9m111 = {