This is not how any of this is supposed to work, it's unlikely to work well with other devices. If the device supports both master and slave operation then you should let the machine driver pick if the SoC or the CODEC is master via set_fmt(), randomly varying this at runtime is not going to be helpful.
Maybe the name "master/slave" is confusing, these names come from internal chip signals and do not represent the state of the i2s bus master. Our SoC supports only master mode in the i2s bus. The Rx and Tx block each have an independent bit to indicate if it is generating the clock for the i2s bus. The i2s bus clocks need to be generated from either the Rx block or the Tx block, but not both.