0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 #include "dce_i2c.h"
0026 #include "reg_helper.h"
0027
0028 bool dce_i2c_oem_device_present(
0029 struct resource_pool *pool,
0030 struct ddc_service *ddc,
0031 size_t slave_address
0032 )
0033 {
0034 struct dc *dc = ddc->ctx->dc;
0035 struct dc_bios *dcb = dc->ctx->dc_bios;
0036 struct graphics_object_id id = {0};
0037 struct graphics_object_i2c_info i2c_info;
0038
0039 if (!dc->ctx->dc_bios->fw_info.oem_i2c_present)
0040 return false;
0041
0042 id.id = dc->ctx->dc_bios->fw_info.oem_i2c_obj_id;
0043 id.enum_id = 0;
0044 id.type = OBJECT_TYPE_GENERIC;
0045 if (dcb->funcs->get_i2c_info(dcb, id, &i2c_info) != BP_RESULT_OK)
0046 return false;
0047
0048 if (i2c_info.i2c_slave_address != slave_address)
0049 return false;
0050
0051 return true;
0052 }
0053
0054 bool dce_i2c_submit_command(
0055 struct resource_pool *pool,
0056 struct ddc *ddc,
0057 struct i2c_command *cmd)
0058 {
0059 struct dce_i2c_hw *dce_i2c_hw;
0060 struct dce_i2c_sw dce_i2c_sw = {0};
0061
0062 if (!ddc) {
0063 BREAK_TO_DEBUGGER();
0064 return false;
0065 }
0066
0067 if (!cmd) {
0068 BREAK_TO_DEBUGGER();
0069 return false;
0070 }
0071
0072 dce_i2c_hw = acquire_i2c_hw_engine(pool, ddc);
0073
0074 if (dce_i2c_hw)
0075 return dce_i2c_submit_command_hw(pool, ddc, cmd, dce_i2c_hw);
0076
0077 dce_i2c_sw.ctx = ddc->ctx;
0078 if (dce_i2c_engine_acquire_sw(&dce_i2c_sw, ddc)) {
0079 return dce_i2c_submit_command_sw(pool, ddc, cmd, &dce_i2c_sw);
0080 }
0081
0082 return false;
0083 }